set default timezone to UTC for test runs

This commit is contained in:
Jake McDermott 2019-08-08 14:48:01 -04:00 committed by Marliana Lara
parent 475645f604
commit 2a926fffd9
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
3 changed files with 9 additions and 15 deletions

View File

@ -5,8 +5,8 @@
"main": "index.jsx",
"scripts": {
"start": "webpack-dev-server --config ./webpack.config.js --mode development",
"test": "jest --coverage",
"test-watch": "jest --watch",
"test": "TZ='UTC' jest --coverage",
"test-watch": "TZ='UTC' jest --watch",
"lint": "eslint --ext .js --ext .jsx .",
"add-locale": "lingui add-locale",
"extract-strings": "lingui extract",

View File

@ -24,12 +24,6 @@ const selectors = {
lineText: 'JobEvent__JobEventLineText',
};
function tzHours(hours) {
const date = new Date();
date.setUTCHours(hours);
return date.getHours();
}
describe('<JobEvent />', () => {
test('initially renders successfully', () => {
mountWithContexts(<JobEvent {...mockOnPlayStartEvent} />);
@ -39,7 +33,7 @@ describe('<JobEvent />', () => {
let wrapper = mountWithContexts(<JobEvent {...mockOnPlayStartEvent} />);
let lineText = wrapper.find(selectors.lineText);
expect(
lineText.filterWhere(e => e.html().includes(`${tzHours(18)}:11:22`))
lineText.filterWhere(e => e.text().includes('18:11:22'))
).toHaveLength(1);
const singleDigitTimestampEvent = {
@ -49,7 +43,7 @@ describe('<JobEvent />', () => {
wrapper = mountWithContexts(<JobEvent {...singleDigitTimestampEvent} />);
lineText = wrapper.find(selectors.lineText);
expect(
lineText.filterWhere(e => e.html().includes(`${tzHours(8)}:01:02`))
lineText.filterWhere(e => e.text().includes('08:01:02'))
).toHaveLength(1);
});

View File

@ -8,7 +8,7 @@ import mockJobEventsData from './data.job_events.json';
jest.mock('@api');
async function checkOutput(wrapper, expectedLines) {
await waitForElement(wrapper, 'div[type="job_event"]', e => e.length > 1);
await waitForElement(wrapper, 'div[type="job_event"]', el => el.length > 1);
const jobEventLines = wrapper.find('div[type="job_event_line_text"]');
const actualLines = [];
jobEventLines.forEach(line => {
@ -65,9 +65,9 @@ describe('<JobOutput />', () => {
await waitForElement(wrapper, 'JobEvent', el => el.length > 0);
await checkOutput(wrapper, [
'',
'PLAY [all] *********************************************************************11:37:25',
'PLAY [all] *********************************************************************15:37:25',
'',
'TASK [debug] *******************************************************************11:37:25',
'TASK [debug] *******************************************************************15:37:25',
'ok: [localhost] => (item=1) => {',
' "msg": "This is a debug message: 1"',
'}',
@ -171,7 +171,7 @@ describe('<JobOutput />', () => {
'handleScrollLast'
);
wrapper = mountWithContexts(<JobOutput job={mockJob} />);
await waitForElement(wrapper, 'EmptyStateBody', e => e.length === 0);
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
wrapper
.find('JobOutput')
.instance()
@ -190,7 +190,7 @@ describe('<JobOutput />', () => {
test('should throw error', async done => {
JobsAPI.readEvents = () => Promise.reject(new Error());
wrapper = mountWithContexts(<JobOutput job={mockJob} />);
await waitForElement(wrapper, 'ContentError', e => e.length === 1);
await waitForElement(wrapper, 'ContentError', el => el.length === 1);
done();
});
});