Skip to content

Commit

Permalink
Fixed tests failing due to server timezone difference
Browse files Browse the repository at this point in the history
  • Loading branch information
ranbena committed Jan 13, 2019
1 parent 6af9186 commit a746c6f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { configure } from 'enzyme';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });
5 changes: 5 additions & 0 deletions client/app/__tests__/mocks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import MockDate from 'mockdate';

const date = new Date('2000-01-01T02:00:00.000');

MockDate.set(date);
5 changes: 0 additions & 5 deletions client/app/components/queries/ScheduleDialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ function getSelectOptions(wrapper) {
}

describe('ScheduleDialog', () => {
beforeAll(() => {
// mock date string so snapshots don't get invalidated
window.Date.prototype.toISOString = jest.fn(() => 'mocked ISO');
});

describe('Sets correct schedule settings', () => {
test('Sets to "Never"', () => {
const [wrapper] = getWrapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ exports[`ScheduleDialog Sets correct schedule settings Sets to "1 Day 22:15" Set
}
}
allowEmpty={false}
defaultValue={"mocked ISO"}
defaultValue={"1999-12-31T22:15:00.000Z"}
disabled={false}
focusOnOpen={true}
format="HH:mm"
Expand Down Expand Up @@ -304,7 +304,7 @@ exports[`ScheduleDialog Sets correct schedule settings Sets to "1 Day 22:15" Set
className=""
clearText="clear"
defaultOpen={false}
defaultOpenValue={"mocked ISO"}
defaultOpenValue={"2000-01-01T00:00:00.000Z"}
disabled={false}
disabledHours={[Function]}
disabledMinutes={[Function]}
Expand All @@ -331,7 +331,7 @@ exports[`ScheduleDialog Sets correct schedule settings Sets to "1 Day 22:15" Set
style={Object {}}
transitionName="slide-up"
use12Hours={false}
value={"mocked ISO"}
value={"1999-12-31T22:15:00.000Z"}
>
<Trigger
action={
Expand Down Expand Up @@ -435,7 +435,7 @@ exports[`ScheduleDialog Sets correct schedule settings Sets to "1 Day 22:15" Set
addon={[Function]}
allowEmpty={false}
clearText="clear"
defaultOpenValue={"mocked ISO"}
defaultOpenValue={"2000-01-01T00:00:00.000Z"}
disabledHours={[Function]}
disabledMinutes={[Function]}
disabledSeconds={[Function]}
Expand All @@ -454,7 +454,7 @@ exports[`ScheduleDialog Sets correct schedule settings Sets to "1 Day 22:15" Set
showMinute={true}
showSecond={false}
use12Hours={false}
value={"mocked ISO"}
value={"1999-12-31T22:15:00.000Z"}
/>
}
popupAlign={
Expand Down Expand Up @@ -1030,7 +1030,7 @@ exports[`ScheduleDialog Sets correct schedule settings Sets to "2 Weeks 22:15 Tu
}
}
allowEmpty={false}
defaultValue={"mocked ISO"}
defaultValue={"1999-12-31T22:15:00.000Z"}
disabled={false}
focusOnOpen={true}
format="HH:mm"
Expand Down Expand Up @@ -1064,7 +1064,7 @@ exports[`ScheduleDialog Sets correct schedule settings Sets to "2 Weeks 22:15 Tu
className=""
clearText="clear"
defaultOpen={false}
defaultOpenValue={"mocked ISO"}
defaultOpenValue={"2000-01-01T00:00:00.000Z"}
disabled={false}
disabledHours={[Function]}
disabledMinutes={[Function]}
Expand All @@ -1091,7 +1091,7 @@ exports[`ScheduleDialog Sets correct schedule settings Sets to "2 Weeks 22:15 Tu
style={Object {}}
transitionName="slide-up"
use12Hours={false}
value={"mocked ISO"}
value={"1999-12-31T22:15:00.000Z"}
>
<Trigger
action={
Expand Down Expand Up @@ -1195,7 +1195,7 @@ exports[`ScheduleDialog Sets correct schedule settings Sets to "2 Weeks 22:15 Tu
addon={[Function]}
allowEmpty={false}
clearText="clear"
defaultOpenValue={"mocked ISO"}
defaultOpenValue={"2000-01-01T00:00:00.000Z"}
disabledHours={[Function]}
disabledMinutes={[Function]}
disabledSeconds={[Function]}
Expand All @@ -1214,7 +1214,7 @@ exports[`ScheduleDialog Sets correct schedule settings Sets to "2 Weeks 22:15 Tu
showMinute={true}
showSecond={false}
use12Hours={false}
value={"mocked ISO"}
value={"1999-12-31T22:15:00.000Z"}
/>
}
popupAlign={
Expand Down Expand Up @@ -2308,7 +2308,7 @@ exports[`ScheduleDialog Sets correct schedule settings Until feature Until is se
prefixCls="ant-calendar"
size="small"
transitionName="slide-up"
value={"mocked ISO"}
value={"2029-12-31T22:00:00.000Z"}
>
<LocaleReceiver
componentName="DatePicker"
Expand Down Expand Up @@ -2372,7 +2372,7 @@ exports[`ScheduleDialog Sets correct schedule settings Until feature Until is se
size="small"
timePicker={null}
transitionName="slide-up"
value={"mocked ISO"}
value={"2029-12-31T22:00:00.000Z"}
>
<span
className="datepicker ant-calendar-picker ant-calendar-picker-small"
Expand All @@ -2386,7 +2386,7 @@ exports[`ScheduleDialog Sets correct schedule settings Until feature Until is se
<Calendar
className=""
dateInputPlaceholder="Select date"
defaultValue={"mocked ISO"}
defaultValue={"2000-01-01T00:00:00.000Z"}
disabledTime={null}
format="YYYY-MM-DD"
locale={
Expand Down Expand Up @@ -2437,7 +2437,7 @@ exports[`ScheduleDialog Sets correct schedule settings Until feature Until is se
showToday={true}
style={Object {}}
timePicker={null}
value={"mocked ISO"}
value={"2029-12-31T22:00:00.000Z"}
visible={true}
/>
}
Expand Down Expand Up @@ -2500,7 +2500,7 @@ exports[`ScheduleDialog Sets correct schedule settings Until feature Until is se
style={Object {}}
timePicker={null}
transitionName="slide-up"
value={"mocked ISO"}
value={"2029-12-31T22:00:00.000Z"}
>
<Trigger
action={
Expand Down Expand Up @@ -2602,7 +2602,7 @@ exports[`ScheduleDialog Sets correct schedule settings Until feature Until is se
<Calendar
className=""
dateInputPlaceholder="Select date"
defaultValue={"mocked ISO"}
defaultValue={"2029-12-31T22:00:00.000Z"}
disabledTime={null}
format="YYYY-MM-DD"
locale={
Expand Down Expand Up @@ -2649,12 +2649,12 @@ exports[`ScheduleDialog Sets correct schedule settings Until feature Until is se
prefixCls="ant-calendar"
renderFooter={[Function]}
renderSidebar={[Function]}
selectedValue={"mocked ISO"}
selectedValue={"2029-12-31T22:00:00.000Z"}
showDateInput={true}
showToday={true}
style={Object {}}
timePicker={null}
value={"mocked ISO"}
value={"2029-12-31T22:00:00.000Z"}
visible={true}
/>
}
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"watch": "webpack --watch --progress --colors -d",
"analyze": "npm run clean && BUNDLE_ANALYZER=on webpack",
"analyze:build": "npm run clean && NODE_ENV=production BUNDLE_ANALYZER=on webpack",
"test": "jest",
"test": "TZ=Asia/Jerusalem jest",
"test:watch": "jest --watch",
"cypress:install": "npm install --no-save cypress @percy/cypress",
"cypress": "node cypress/cypress.js"
Expand Down Expand Up @@ -116,6 +116,7 @@
"less-loader": "^4.1.0",
"less-plugin-autoprefix": "^1.5.1",
"mini-css-extract-plugin": "^0.4.4",
"mockdate": "^2.0.2",
"raw-loader": "^0.5.1",
"react-test-renderer": "^16.5.2",
"request": "^2.88.0",
Expand All @@ -132,14 +133,18 @@
},
"jest": {
"setupFiles": [
"./client/app/jest_setup.js"
"./client/app/__tests__/enzyme_setup.js",
"./client/app/__tests__/mocks.js"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"moduleNameMapper": {
"^@/(.*)": "<rootDir>/client/app/$1",
"\\.(css|less)$": "identity-obj-proxy"
}
},
"testPathIgnorePatterns": [
"<rootDir>/client/app/__tests__/"
]
}
}

0 comments on commit a746c6f

Please sign in to comment.