Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
Merge pull request #86 from andymikulski/72-karma
Browse files Browse the repository at this point in the history
#72 Part 2: Karma Boogaloo: Jest's Revenge
  • Loading branch information
andymikulski committed Apr 5, 2018
2 parents 08c0c35 + dbc2515 commit e62dc3a
Show file tree
Hide file tree
Showing 82 changed files with 127 additions and 1,827 deletions.
11 changes: 11 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"overrides": [{
"files": "**/*.test.js",
"globals": {
"shallow": true,
"React": true,
"ReactDOM": true,
"mount": true
}
}]
}
89 changes: 0 additions & 89 deletions karma.conf.js

This file was deleted.

19 changes: 4 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@
"build": "react-app-rewired build",
"build-stage": "REACT_APP_SENTRY_PUBLIC_DSN='https://7f037ccfad184848848bd5077d9ecf07@sentry.prod.mozaws.net/362' build",
"build-prod": "REACT_APP_SENTRY_PUBLIC_DSN='https://4dac38d672e842a88233e9293caf2d09@sentry.prod.mozaws.net/363' build",
"test": "CI=true yarn run test:jest && yarn run test:karma",
"test": "CI=true yarn run test:jest",
"test:jest": "react-app-rewired test --env=jsdom",
"test:karma": "BABEL_ENV=development NODE_ENV=development karma start",
"eject": "react-scripts eject",
"lint:flow": "flow",
"lint:less": "stylelint 'src/**/*.less' --config .stylelintrc",
"lint:eslint": "eslint -c node_modules/eslint-config-react-app/index.js --max-warnings 0 'src/**/*.js'",
"lint:eslintfix": "eslint -c node_modules/eslint-config-react-app/index.js --max-warnings 0 --fix 'src/**/*.js'",
"lint:prettier-eslint": "prettier-eslint --list-different 'src/**/*.js' | ./lint_problems.sh && yarn run lint:eslint",
"lint:prettier-eslintfix": "prettier-eslint --write 'src/**/*.js' && yarn run lint:eslintfix",
"lint:prettier-eslint": "prettier-eslint --list-different 'src/**/*.js' | ./lint_problems.sh",
"lint:prettier-eslintfix": "prettier-eslint --write 'src/**/*.js'",
"lint": "yarn run lint:flow && yarn run lint:prettier-eslint && yarn run lint:eslint && yarn run lint:less"
},
"devDependencies": {
Expand All @@ -51,18 +50,8 @@
"enzyme": "3.3.0",
"faker": "4.1.0",
"flow-bin": "0.69.0",
"jest-immutable-matchers": "2.0.1",
"pre-commit": "1.2.2",
"jasmine": "3.1.0",
"jasmine-immutable-matchers": "2.0.1",
"jasmine-promises": "0.4.1",
"karma": "2.0.0",
"karma-firefox-launcher": "1.1.0",
"karma-jasmine": "1.1.1",
"karma-junit-reporter": "1.2.0",
"karma-react-jsx-preprocessor": "0.1.1",
"karma-sourcemap-loader": "0.3.7",
"karma-spec-reporter": "0.0.32",
"karma-webpack": "3.0.0",
"prettier": "1.11.1",
"prettier-eslint": "8.8.1",
"prettier-eslint-cli": "4.7.1",
Expand Down
32 changes: 0 additions & 32 deletions src/console/App.test.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,4 @@
import React from 'react';
import App from './App';
import { shallow } from 'enzyme';

// Mock the localStorage API.
global.localStorage = (function() {
var store = {};

return {
getItem: function(key) {
return store[key] || null;
},
removeItem: function(key) {
delete store[key];
},
setItem: function(key, value) {
store[key] = value.toString();
},
clear: function() {
store = {};
},
};
})();

const webAuthMock = {
authorize: jest.fn(),
parseHash: jest.fn(),
client: { userInfo: jest.fn() },
};

global.auth0 = {
WebAuth: jest.fn(() => webAuthMock),
};

describe('delivery-console', () => {
it('renders without crashing', () => {
Expand Down
13 changes: 0 additions & 13 deletions src/normandy/App.test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
import React from 'react';
import App from './App';
import { shallow } from 'enzyme';

describe('normandy', () => {
beforeAll(() => {
const fakeStorage = {
store: {},
getItem: key => fakeStorage.store[key] || null,
setItem: (key, value) => (fakeStorage.store[key] = value),
};
Object.defineProperty(window, 'localStorage', {
value: fakeStorage,
});
});

it('renders without crashing', () => {
const wrapper = () => shallow(<App />);
expect(wrapper).not.toThrow();
Expand Down
2 changes: 1 addition & 1 deletion src/normandy/components/recipes/RecipeDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class RecipeDetails extends React.PureComponent {
export class ArgumentsValue extends React.PureComponent {
static propTypes = {
name: PropTypes.string,
value: PropTypes.any.isRequired,
value: PropTypes.any,
};

static defaultProps = {
Expand Down
2 changes: 0 additions & 2 deletions src/normandy/tests/.eslintrc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { shallow } from 'enzyme';

import App from 'normandy/components/App';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow } from 'enzyme';

import BooleanIcon from 'normandy/components/common/BooleanIcon';

describe('<BooleanIcon>', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow } from 'enzyme';

import CheckboxMenu from 'normandy/components/common/CheckboxMenu';

describe('<CheckboxMenu>', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';
import { mount } from 'enzyme';
import EnrollmentStatus from 'normandy/components/common/EnrollmentStatus';
import { wrapMockStore } from 'normandy/tests/mockStore';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import TestComponent from 'normandy/components/common/EnvAlert';

const { WrappedComponent: EnvAlert } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { Spin } from 'antd';
import React from 'react';
import { shallow, mount } from 'enzyme';

import LoadingOverlay, {
SimpleLoadingOverlay,
} from 'normandy/components/common/LoadingOverlay';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { List } from 'immutable';
import React from 'react';
import { shallow } from 'enzyme';

import NavigationMenu from 'normandy/components/common/NavigationMenu';

describe('<NavigationMenu>', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { mount } from 'enzyme';

import ShieldIdenticon from 'normandy/components/common/ShieldIdenticon';

describe('<ShieldIdenticon>', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import TestComponent from 'normandy/components/data/QueryActions';

const { WrappedComponent: QueryActions } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import TestComponent from 'normandy/components/data/QueryExtension';

const { WrappedComponent: QueryExtension } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import TestComponent from 'normandy/components/data/QueryExtensionListingColumns';

const { WrappedComponent: QueryExtensionListingColumns } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { Map } from 'immutable';
import React from 'react';
import { shallow, mount } from 'enzyme';

import TestComponent from 'normandy/components/data/QueryFilteredRecipes';

const { WrappedComponent: QueryFilteredRecipes } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import TestComponent from 'normandy/components/data/QueryMultipleExtensions';

const { WrappedComponent: QueryMultipleExtensions } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import TestComponent from 'normandy/components/data/QueryRecipe';

const { WrappedComponent: QueryRecipe } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import TestComponent from 'normandy/components/data/QueryRecipeHistory';

const { WrappedComponent: QueryRecipeHistory } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import TestComponent from 'normandy/components/data/QueryRecipeListingColumns';

const { WrappedComponent: QueryRecipeListingColumns } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import TestComponent from 'normandy/components/data/QueryRevision';

const { WrappedComponent: QueryRevision } = TestComponent;

describe('<QueryRevision>', () => {
const props = {
fetchRevision: () => {},
pk: 1,
pk: '1',
};

it('should work', () => {
Expand Down Expand Up @@ -43,16 +40,16 @@ describe('<QueryRevision>', () => {
);
expect(callCount).toBe(1);

wrapper.setProps({ pk: 2 });
wrapper.setProps({ pk: '2' });
expect(callCount).toBe(2);

wrapper.setProps({ irrelevant: true });
expect(callCount).toBe(2);

wrapper.setProps({ pk: 2 });
wrapper.setProps({ pk: '2' });
expect(callCount).toBe(2);

wrapper.setProps({ pk: 3 });
wrapper.setProps({ pk: '3' });
expect(callCount).toBe(3);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import TestComponent from 'normandy/components/data/QueryServiceInfo';

const { WrappedComponent: QueryServiceInfo } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow } from 'enzyme';

import TestComponent from 'normandy/components/extensions/CreateExtensionPage';

const { WrappedComponent: CreateExtensionPage } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow } from 'enzyme';

import QueryExtension from 'normandy/components/data/QueryExtension';
import TestComponent from 'normandy/components/extensions/EditExtensionPage';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import React from 'react';
import { shallow } from 'enzyme';

import TestComponent from 'normandy/components/extensions/ExtensionForm';

const { WrappedComponent: ExtensionForm } = TestComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { List } from 'immutable';
import React from 'react';
import { shallow } from 'enzyme';

import TestComponent from 'normandy/components/extensions/ExtensionListing';

const { WrappedComponent: ExtensionListing } = TestComponent;
Expand Down

0 comments on commit e62dc3a

Please sign in to comment.