Skip to content

Commit

Permalink
Always require flow annotation & introduce editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslav-kubicek committed Mar 14, 2018
1 parent e384c69 commit fb4b61f
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 9 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"prettier/react"
],
"plugins": [
"import",
"flowtype",
"prettier",
"jest"
Expand All @@ -33,6 +34,7 @@
"react/require-default-props": "off", // Optional props can be undefined.
"react/jsx-filename-extension": ["error", { "extensions": [".js"] }], // Don't use jsx
"jsx-a11y/label-has-for": "off", // control is wrapped in a label
"jsx-a11y/href-no-hash": "off" // broken rule
"jsx-a11y/href-no-hash": "off", // broken rule
"flowtype/require-valid-file-annotation": ["error", "always"]
}
}
1 change: 1 addition & 0 deletions config/build.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @noflow
/* eslint-disable import/no-extraneous-dependencies */
const path = require("path");
const fs = require("fs");
Expand Down
2 changes: 2 additions & 0 deletions config/enzymeConfig.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @flow

import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";

Expand Down
4 changes: 3 additions & 1 deletion src/Button/__tests__/IconWrapper.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// @flow

import * as React from "react";
import { shallow } from "enzyme";
import { Money } from "@kiwicom/icons";
import IconWrapper from "../IconWrapper";

describe("IconWrapper", () => {
const component = shallow(<IconWrapper Icon={Money} />);
const component = shallow(<IconWrapper size="normal" type="primary" Icon={Money} />);

it("should contain component named the same as imported icon", () => {
expect(component.find("Money").exists()).toBe(true);
Expand Down
16 changes: 12 additions & 4 deletions src/Button/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// @flow

import * as React from "react";
import { shallow } from "enzyme";
import Button from "../";

describe("Button", () => {
const title = "Title";
const component = shallow(<Button title={title} />);
const component = shallow(
<Button title={title} size="normal" type="primary" onClick={jest.fn()} />,
);
const button = component.find("button");
it("Should contain a title ", () => {
expect(button.render().text()).toBe(title);
Expand All @@ -14,7 +18,9 @@ describe("Button", () => {
describe("When button is clicked", () => {
const onClick = jest.fn();
const title = "title";
const component = shallow(<Button title={title} onClick={onClick} />);
const component = shallow(
<Button type="primary" size="normal" title={title} onClick={onClick} />,
);
const button = component.find("button");

it("should execute onClick method", () => {
Expand All @@ -25,8 +31,10 @@ describe("When button is clicked", () => {

describe("Rendered with icon", () => {
const title = "title";
const icon = jest.fn();
const component = shallow(<Button title={title} Icon={icon} />);
const icon = () => <i />;
const component = shallow(
<Button type="primary" size="normal" title={title} Icon={icon} onClick={jest.fn()} />,
);
const button = component.find("button");
it("Should contain IconWrapper", () => {
expect(button.find("IconWrapper").exists()).toBe(true);
Expand Down
5 changes: 4 additions & 1 deletion src/SystemMessage/__tests__/IconWrapper.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// @flow

import * as React from "react";
import { shallow } from "enzyme";
import IconWrapper from "../IconWrapper";

describe("System Message", () => {
const component = shallow(<IconWrapper type="success" Icon="Icon" />);
const Icon = () => <i />;
const component = shallow(<IconWrapper type="success" Icon={Icon} />);

it("Should contain Icon", () => {
expect(component.find("Icon").exists()).toBe(true);
Expand Down
2 changes: 2 additions & 0 deletions src/SystemMessage/__tests__/Title.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @flow

import * as React from "react";
import { shallow } from "enzyme";
import Title from "../Title";
Expand Down
4 changes: 3 additions & 1 deletion src/SystemMessage/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @flow

import * as React from "react";
import { shallow } from "enzyme";
import SystemMessage from "../";
Expand All @@ -17,7 +19,7 @@ describe("Rendered with title ", () => {
});

describe("Rendered with icon ", () => {
const icon = jest.fn();
const icon = () => <i />;
const componentWithIcon = shallow(<SystemMessage type="success" Icon={icon} />);
it("Should contain IconWrapper", () => {
expect(componentWithIcon.find("IconWrapper").exists()).toBe(true);
Expand Down
5 changes: 5 additions & 0 deletions src/icons/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"flowtype/require-valid-file-annotation": "off"
}
}
3 changes: 2 additions & 1 deletion src/icons/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
!/png/
!icons.md
!readme.md
!.gitignore
!.gitignore
!.eslintrc

0 comments on commit fb4b61f

Please sign in to comment.