Skip to content

Commit

Permalink
add: eslint and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
s4l1h committed Aug 11, 2019
1 parent 456b209 commit fe0f178
Show file tree
Hide file tree
Showing 30 changed files with 1,079 additions and 547 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lib/
test-utils/
node_modules/
29 changes: 29 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": false,
"codeFrame": false
},
"extends": [
"airbnb",
"plugin:react/recommended",
"prettier",
"prettier/react"
],
"env": {
"browser": true,
"jest": true
},
"rules": {
"import/no-extraneous-dependencies": ["off"],
"react/jsx-fragments": ["off"],
"react/forbid-prop-types": ["off"],
"react/jsx-props-no-spreading": ["off"],
"max-len": ["error", { "code": 100 }],
"prefer-promise-reject-errors": ["off"],
"react/jsx-filename-extension": ["off"],
"react/prop-types": ["warn"],
"no-return-assign": ["off"]
}
}
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ node_js:
cache: yarn
install: yarn
script:
#- yarn lint
- yarn lint
- yarn format
- yarn test
jobs:
include:
- stage: npm release
if: tag IS present
node_js: "12"
script: yarn build
script:
- yarn test
- yarn build
deploy:
provider: npm
email: "$NPM_EMAIL"
Expand Down
14 changes: 2 additions & 12 deletions __tests__/Consumer.Context.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
// __tests__/hidden-message.js
// these imports are something you'd normally configure Jest to import for you
// automatically. Learn more in the setup docs: https://testing-library.com/docs/react-testing-library/setup#cleanup
// import "@testing-library/react/cleanup-after-each";
import "@testing-library/jest-dom/extend-expect";

// NOTE: jest-dom adds handy assertions to Jest and is recommended, but not required

import React from "react";
import { fireEvent, cleanup } from "@testing-library/react";
import {
renderWithProvider,
SampleConsumerContext
} from "../src/utils/test-utils";
import { fireEvent } from "@testing-library/react";
import { renderWithProvider, SampleConsumerContext } from "../test-utils";

describe("Toasted Consumer", () => {
const { container, getByText } = renderWithProvider(
Expand Down
14 changes: 2 additions & 12 deletions __tests__/Consumer.ContextType.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
// __tests__/hidden-message.js
// these imports are something you'd normally configure Jest to import for you
// automatically. Learn more in the setup docs: https://testing-library.com/docs/react-testing-library/setup#cleanup
// import "@testing-library/react/cleanup-after-each";
import "@testing-library/jest-dom/extend-expect";

// NOTE: jest-dom adds handy assertions to Jest and is recommended, but not required

import React from "react";
import { fireEvent, cleanup } from "@testing-library/react";
import {
renderWithProvider,
SampleConsumerContextType
} from "../src/utils/test-utils";
import { fireEvent } from "@testing-library/react";
import { renderWithProvider, SampleConsumerContextType } from "../test-utils";

describe("Toasted Consumer useContext", () => {
const { container, getByText } = renderWithProvider(
Expand Down
14 changes: 2 additions & 12 deletions __tests__/Consumer.UseContext.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
// __tests__/hidden-message.js
// these imports are something you'd normally configure Jest to import for you
// automatically. Learn more in the setup docs: https://testing-library.com/docs/react-testing-library/setup#cleanup
// import "@testing-library/react/cleanup-after-each";
import "@testing-library/jest-dom/extend-expect";

// NOTE: jest-dom adds handy assertions to Jest and is recommended, but not required

import React from "react";
import { fireEvent, cleanup } from "@testing-library/react";
import {
renderWithProvider,
SampleConsumerUseContext
} from "../src/utils/test-utils";
import { fireEvent } from "@testing-library/react";
import { renderWithProvider, SampleConsumerUseContext } from "../test-utils";

describe("Toasted Consumer useContext", () => {
const { container, getByText } = renderWithProvider(
Expand Down
55 changes: 0 additions & 55 deletions __tests__/Consumer.test.txt

This file was deleted.

7 changes: 1 addition & 6 deletions __tests__/Provider.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// __tests__/hidden-message.js
// these imports are something you'd normally configure Jest to import for you
// automatically. Learn more in the setup docs: https://testing-library.com/docs/react-testing-library/setup#cleanup
// import "@testing-library/react/cleanup-after-each";
import "@testing-library/jest-dom/extend-expect";

import { renderWithProvider } from "../src/utils/test-utils";
import { renderWithProvider } from "../test-utils";

describe("Toasted Provider Snapshot", () => {
test("it has to match snapshot", () => {
Expand Down
23 changes: 9 additions & 14 deletions __tests__/Toast.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
// __tests__/hidden-message.js
// these imports are something you'd normally configure Jest to import for you
// automatically. Learn more in the setup docs: https://testing-library.com/docs/react-testing-library/setup#cleanup
// import "@testing-library/react/cleanup-after-each";
import "@testing-library/jest-dom/extend-expect";

// NOTE: jest-dom adds handy assertions to Jest and is recommended, but not required

import React from "react";
import { render, fireEvent, cleanup } from "@testing-library/react";
import { render, fireEvent } from "@testing-library/react";
import Toast from "../src/components/Toast";

describe("Toast Component Snapshot", () => {
Expand Down Expand Up @@ -37,20 +30,22 @@ describe("Toast Component Snapshot", () => {
});
});
describe("Toast Events", () => {
let toastMessage = "Message";
let onCreated = jest.fn();
let onClicked = jest.fn();
let onMouseOver = jest.fn();
let onMouseOut = jest.fn();
let onDestroyed = jest.fn();
const toastMessage = "Message";
const onCreated = jest.fn();
const onClicked = jest.fn();
const onMouseOver = jest.fn();
const onMouseOut = jest.fn();
const onDestroyed = jest.fn();
const { getByText, unmount } = render(
<Toast
msg={toastMessage}
position="toast-top-right"
onCreated={onCreated}
onClick={onClicked}
onMouseOver={onMouseOver}
onFocus={onMouseOver}
onMouseOut={onMouseOut}
onBlur={onMouseOut}
onDestroyed={onDestroyed}
/>
);
Expand Down
20 changes: 7 additions & 13 deletions __tests__/ToastContainer.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
// __tests__/hidden-message.js
// these imports are something you'd normally configure Jest to import for you
// automatically. Learn more in the setup docs: https://testing-library.com/docs/react-testing-library/setup#cleanup
// import "@testing-library/react/cleanup-after-each";
import "@testing-library/jest-dom/extend-expect";

// NOTE: jest-dom adds handy assertions to Jest and is recommended, but not required

import React from "react";
import { render, fireEvent, cleanup } from "@testing-library/react";
import { render } from "@testing-library/react";
import ToastContainer from "../src/components/ToastContainer";

describe("ToastContainer Snapshot", () => {
Expand All @@ -29,7 +22,7 @@ describe("ToastContainer Snapshot", () => {
defaultProgressBarValue: 0,
defaultPreventDuplicates: false,
defaultStyle: {}
//defaultPositions: positions
// defaultPositions: positions
}}
/>
);
Expand All @@ -42,6 +35,7 @@ describe("ToastContainer Functions", () => {
const { container } = render(
<ToastContainer
ref={ref}
// eslint-disable-next-line
{...{
defaultClassNames: ["animated", "zoomInUp"], // need animated.css
defaultPosition: "toast-top-right",
Expand All @@ -53,11 +47,11 @@ describe("ToastContainer Functions", () => {
defaultProgressBarValue: 0,
defaultPreventDuplicates: false,
defaultStyle: {}
//defaultPositions: positions
// defaultPositions: positions
}}
/>
);
let component = ref.current;
const component = ref.current;
test("it tests short functions", () => {
component.s("Success Message");
component.i("Information Message");
Expand All @@ -77,10 +71,10 @@ describe("ToastContainer Functions", () => {
});

test("it tests add and remove function", () => {
let msg = "Hello Dear";
const msg = "Hello Dear";
component.add({
name: "mytoast",
msg: msg
msg
});
expect(container.innerHTML).toMatch(msg);

Expand Down
7 changes: 0 additions & 7 deletions __tests__/ToastProgress.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// __tests__/hidden-message.js
// these imports are something you'd normally configure Jest to import for you
// automatically. Learn more in the setup docs: https://testing-library.com/docs/react-testing-library/setup#cleanup
// import "@testing-library/react/cleanup-after-each";
import "@testing-library/jest-dom/extend-expect";

// NOTE: jest-dom adds handy assertions to Jest and is recommended, but not required

import React from "react";
import { render } from "@testing-library/react";
import ToastProgress from "../src/components/ToastProgress";
Expand Down
2 changes: 2 additions & 0 deletions __tests__/__snapshots__/Toast.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`Toast Component Snapshot basic toast snapshot 1`] = `
<div>
<div
class="toast toast-success"
role="presentation"
>
<div
class="toast-message"
Expand All @@ -16,6 +17,7 @@ exports[`Toast Component Snapshot it has to match snapshot 1`] = `
<div>
<div
class="toast toast-success animated"
role="presentation"
style="color: red;"
>
<div
Expand Down
12 changes: 1 addition & 11 deletions __tests__/witToasted.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
// __tests__/hidden-message.js
// these imports are something you'd normally configure Jest to import for you
// automatically. Learn more in the setup docs: https://testing-library.com/docs/react-testing-library/setup#cleanup
// import "@testing-library/react/cleanup-after-each";
import "@testing-library/jest-dom/extend-expect";

// NOTE: jest-dom adds handy assertions to Jest and is recommended, but not required

import React from "react";
import { fireEvent } from "@testing-library/react";
import {
renderWithProvider,
WithToastedComponent
} from "../src/utils/test-utils";
import { renderWithProvider, WithToastedComponent } from "../test-utils";

describe("Toasted withToasted", () => {
const { container, getByText } = renderWithProvider(<WithToastedComponent />);
Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module.export = {
moduleFileExtensions: ["js", "jsx", "json", "node"],
testPathIgnorePatterns: ["/node_modules/"],
setupFilesAfterEnv: [
//"@testing-library/react/cleanup-after-each",
//"@testing-library/jest-dom/extend-expect"
// "@testing-library/react/cleanup-after-each",
// "@testing-library/jest-dom/extend-expect"
// setupFiles before the tests are ran
]
};
Loading

0 comments on commit fe0f178

Please sign in to comment.