Skip to content

Commit

Permalink
Fix failing tests, upgrade testing environment
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Dec 10, 2017
1 parent 235b830 commit a8a8b7a
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 36 deletions.
4 changes: 4 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

Enzyme.configure({ adapter: new Adapter() });
5 changes: 5 additions & 0 deletions jest.shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if (!global.requestAnimationFrame) {
global.requestAnimationFrame = function(callback) {
setTimeout(callback, 0);
};
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"test-jest-coverage": "jest --coverage"
},
"jest": {
"setupFiles": [
"<rootDir>/jest.shim.js",
"<rootDir>/jest.setup.js"
],
"collectCoverageFrom": [
"**/src/**.{js,jsx}",
"!**/src/entry.js"
Expand Down
5 changes: 1 addition & 4 deletions src/Calendar/__tests__/Navigation.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from 'react';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { shallow } from 'enzyme';

import Navigation from '../Navigation';

configure({ adapter: new Adapter() });

const allViews = ['century', 'decade', 'year', 'month'];

/* eslint-disable comma-dangle */
Expand Down
5 changes: 1 addition & 4 deletions src/MonthView/__tests__/WeekNumbers.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from 'react';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { shallow } from 'enzyme';

import WeekNumbers from '../WeekNumbers';

configure({ adapter: new Adapter() });

/* eslint-disable comma-dangle */

describe('WeekNumbers', () => {
Expand Down
5 changes: 1 addition & 4 deletions src/__tests__/Calendar.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { mount } from 'enzyme';

import Calendar from '../Calendar';
import {
getBeginOfMonth,
getISOLocalDate,
} from '../shared/dates';

configure({ adapter: new Adapter() });

/* eslint-disable comma-dangle */

const midnightTimestamp = 'T00:00:00.000';
Expand Down
5 changes: 1 addition & 4 deletions src/__tests__/CenturyView.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { mount } from 'enzyme';

import CenturyView from '../CenturyView';

configure({ adapter: new Adapter() });

/* eslint-disable comma-dangle */

const midnightTimestamp = 'T00:00:00.000';
Expand Down
5 changes: 1 addition & 4 deletions src/__tests__/DecadeView.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { mount } from 'enzyme';

import DecadeView from '../DecadeView';

configure({ adapter: new Adapter() });

/* eslint-disable comma-dangle */

const midnightTimestamp = 'T00:00:00.000';
Expand Down
5 changes: 1 addition & 4 deletions src/__tests__/Flex.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from 'react';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { shallow } from 'enzyme';

import Flex from '../Flex';

configure({ adapter: new Adapter() });

/* eslint-disable comma-dangle */

describe('Flex', () => {
Expand Down
5 changes: 1 addition & 4 deletions src/__tests__/MonthView.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { mount } from 'enzyme';

import MonthView from '../MonthView';
import {
getISOLocalDate,
} from '../shared/dates';

configure({ adapter: new Adapter() });

/* eslint-disable comma-dangle */

const midnightTimestamp = 'T00:00:00.000';
Expand Down
5 changes: 1 addition & 4 deletions src/__tests__/YearView.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { mount } from 'enzyme';

import YearView from '../YearView';
import {
getISOLocalMonth,
} from '../shared/dates';

configure({ adapter: new Adapter() });

/* eslint-disable comma-dangle */

const midnightTimestamp = 'T00:00:00.000';
Expand Down
8 changes: 4 additions & 4 deletions src/shared/__tests__/dates.js
Original file line number Diff line number Diff line change
Expand Up @@ -1097,10 +1097,10 @@ describe('getISOLocalMonth', () => {

it('throws an error when given nonsense data', () => {
const text = 'wololo';
const flag = true;
const fn = () => {};

expect(() => getISOLocalMonth(text)).toThrow();
expect(() => getISOLocalMonth(flag)).toThrow();
expect(() => getISOLocalMonth(fn)).toThrow();
});
});

Expand All @@ -1119,9 +1119,9 @@ describe('getISOLocalDate', () => {

it('throws an error when given nonsense data', () => {
const text = 'wololo';
const flag = true;
const fn = () => {};

expect(() => getISOLocalDate(text)).toThrow();
expect(() => getISOLocalDate(flag)).toThrow();
expect(() => getISOLocalDate(fn)).toThrow();
});
});

0 comments on commit a8a8b7a

Please sign in to comment.