Skip to content

Commit

Permalink
test(store): merge store test files
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandszoke authored and solkimicreb committed Mar 5, 2020
1 parent 03a615c commit c01d000
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 70 deletions.
15 changes: 13 additions & 2 deletions __tests__/store.test.jsx → __tests__/store.no-hook.test.jsx
Expand Up @@ -6,12 +6,23 @@ import { view, store } from 'react-easy-state';
describe('Using an old react version', () => {
afterEach(cleanup);

test('Using local state in a function component should not throw an error', () => {
test(`Using local state in a function component ${
process.env.NOHOOK
? 'with a version of react that has no hooks should'
: 'should not'
} throw an error`, () => {
const MyComp = view(() => {
const person = store({ name: 'Bob' });
return <div>{person.name}</div>;
});
expect(() => render(<MyComp />)).not.toThrow();

if (process.env.NOHOOK) {
expect(() => render(<MyComp />)).toThrow(
'You cannot use state inside a function component with a pre-hooks version of React. Please update your React version to at least v16.8.0 to use this feature.',
);
} else {
expect(() => render(<MyComp />)).not.toThrow();
}
});

test('Using global state in a function component should not throw an error', () => {
Expand Down
67 changes: 0 additions & 67 deletions __tests__/store.test.no-hook.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion jest.no-hook.json
@@ -1,6 +1,6 @@
{
"setupFilesAfterEnv": ["./scripts/testSetup.js"],
"testRegex": "\\.test\\.no-hook\\.jsx?$",
"testRegex": "\\.no-hook\\.test\\.jsx?$",
"collectCoverage": true,
"coverageReporters": ["text"],
"collectCoverageFrom": ["src/**/*.{js,jsx}"],
Expand Down

0 comments on commit c01d000

Please sign in to comment.