Skip to content

Commit

Permalink
resolve flow & jest conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Judahmeek committed Mar 1, 2017
1 parent 994bff3 commit df25a17
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 241 deletions.
1 change: 1 addition & 0 deletions todo-app-production/client/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/flow-typed
10 changes: 2 additions & 8 deletions todo-app-production/client/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@

[libs]
./flow-typed/
./node_modules/fbjs/node_modules/promise
./node_modules/fbjs/flow/lib
./app/libs/interfaces/
node_modules/iflow-immutable/index.js.flow
node_modules/iflow-moment/index.js.flow
node_modules/iflow-react-router/index.js.flow
node_modules/iflow-react-redux-logger/index.js.flow
node_modules/iflow-react-redux-thunk/index.js.flow

[options]
module.system=haste
module.system=node
module.use_strict=true
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

module.name_mapper='.*\.s?css' -> 'CSSModule'
module.name_mapper='.*\.s?css$' -> '<PROJECT_ROOT>/app/libs/interfaces/CSSModule'
module.name_mapper='^app\(.*\)$' -> '<PROJECT_ROOT>/app\1'
module.name_mapper='^todosIndex\(.*\)$' -> '<PROJECT_ROOT>/app/bundles/todosIndex\1'
7 changes: 4 additions & 3 deletions todo-app-production/client/app/libs/interfaces/CSSModule.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
declare module CSSModule {
declare var exports: { [key: ?string]: string };
}
// taken from https://gist.github.com/MoOx/12ac2bee8d876a5c1fe1593e4815895d
type CSSModule = {[key: string]: string};
const emptyCSSModule: CSSModule = {};
export default emptyCSSModule;
185 changes: 0 additions & 185 deletions todo-app-production/client/flow-typed/npm/react-router_vx.x.x.js

This file was deleted.

2 changes: 1 addition & 1 deletion todo-app-production/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"flow": "flow",
"flow:all": "flow --show-all-errors",
"flow:update": "flow-typed update",
"lint": "eslint --ext .js,.jsx .",
"lint": "eslint --fix --ext .js,.jsx .",
"start": "NODE_ENV=dev babel-node server.js",
"storybook": "NODE_ENV=test start-storybook -p 9001 -c .storybook",
"test": "NODE_ENV=test jest .*\\.test\\.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
const path = require('path');

const setContext = require('./set-context');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// @flow
const setDevtool = require('./set-devtool');

describe('webpack-helpers/set-devtool', () => {
test('when builderConfig.devtool is not defined', () => {
describe('when builderConfig.devtool is not defined', () => {
it('outputs to a public path', () => {
const actual = setDevtool({}, {}).devtool;

expect(actual).toBeUndefined();
});
});

test('when builderConfig.sourceMaps is set to "foo"', () => {
describe('when builderConfig.sourceMaps is set to "foo"', () => {
const builderConfig = { sourceMaps: 'foo' };

it('sets config\'s devtool to "foo"', () => {
Expand Down
30 changes: 15 additions & 15 deletions todo-app-production/client/webpack-helpers/set-entry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,44 @@ const setEntry = require('./set-entry');

describe('webpack-helpers/set-entry', () => {
describe('developerAids', () => {
test('when builderConfig.developerAids is true', () => {
describe('when builderConfig.developerAids is true', () => {
const builderConfig = { chunk: true, developerAids: true };

it('uses adds "react-addons-perf" entry to vendor', () => {
const expected = 'react-addons-perf';
const expected = [expect.stringMatching('react-addons-perf')];
const actual = setEntry(builderConfig, {}).entry.vendor;

expect(actual).toBe(expect.stringContaining(expected));
expect(actual).toEqual(expect.arrayContaining(expected));
});
});
});

describe('extractText', () => {
test('when builderConfig.extractText is false', () => {
describe('when builderConfig.extractText is false', () => {
const builderConfig = { chunk: true, extractText: false };

it('uses basic bootstrap loader', () => {
const expected = 'bootstrap-loader';
const expected = [expect.stringMatching('bootstrap-loader')];
const actual = setEntry(builderConfig, {}).entry.vendor;

expect(actual).toBe(expect.stringContaining(expected));
expect(actual).toEqual(expect.arrayContaining(expected));
});
});

test('when builderConfig.extractText is true', () => {
describe('when builderConfig.extractText is true', () => {
const builderConfig = { chunk: true, extractText: true };

it('uses bootstrap extract-styles loader', () => {
const expected = 'bootstrap-loader/extractStyles';
const expected = [expect.stringMatching('bootstrap-loader/extractStyles')];
const actual = setEntry(builderConfig, {}).entry.vendor;

expect(actual).toBe(expect.stringContaining(expected));
expect(actual).toEqual(expect.arrayContaining(expected));
});
});
});

describe('hmr', () => {
test('when builderConfig.hmr is true', () => {
describe('when builderConfig.hmr is true', () => {
const builderConfig = { chunk: true, hmr: true };

it('is not empty', () => {
Expand All @@ -59,14 +59,14 @@ describe('webpack-helpers/set-entry', () => {

expect(entries.length).toBeGreaterThan(0);

const assertIsValidEntry = (entry) => {
const assertIsValidEntry = entry => {
const [entryName, entryLocations] = entry;

if (entryName === 'vendor') return; // vendor stuff isn't hot-reloaded

const [location1, location2] = entryLocations;

expect(location1).toBe(expect.stringMatching(devServerRegEx));
expect(location1).toMatch(devServerRegEx);
expect(location2).toBe(hot);
};

Expand All @@ -76,7 +76,7 @@ describe('webpack-helpers/set-entry', () => {
});

describe('chunk', () => {
test('when builderConfig.chunk is true', () => {
describe('when builderConfig.chunk is true', () => {
const builderConfig = { chunk: true };

it('returns an object with base entry points', () => {
Expand All @@ -85,12 +85,12 @@ describe('webpack-helpers/set-entry', () => {
});
});

test('when builderConfig.chunk is false', () => {
describe('when builderConfig.chunk is false', () => {
const builderConfig = { chunk: false };

it('returns a simple string pointing to the server entry file', () => {
const actual = setEntry(builderConfig, {}).entry;
expect(actual instanceof String).toBe(true);
expect(typeof actual).toBe('string');
});
});
});
Expand Down
Loading

0 comments on commit df25a17

Please sign in to comment.