Skip to content

Commit

Permalink
Fix: date format (#186)
Browse files Browse the repository at this point in the history
* fix: more specific mocked date

* fix: date formating removes timezone

* fix: add label to waitForIFrame error

* fix: remove archive test
  • Loading branch information
milesillsley authored Jun 25, 2019
1 parent 5cdf3f7 commit e25bb8e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 37 deletions.
10 changes: 9 additions & 1 deletion src/remoteActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,15 @@ const archiveRemoteKeys = async (key, config) => {
});
const s3 = new AWS.S3();
const files = fs.readdirSync(imageDir).map(file => `${imageDir}/${file}`);
const date = new Date();
const options = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: 'numeric'
};
const date = new Date().toLocaleDateString('default', options);

if (files.length !== 0) {
logger.info(
Expand Down
36 changes: 1 addition & 35 deletions src/remoteActions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {
listRemoteKeys,
deleteRemoteKeys,
fetchRemoteKeys,
uploadRemoteKeys,
archiveRemoteKeys
uploadRemoteKeys
} from './remoteActions';

jest.mock('fs');
Expand Down Expand Up @@ -174,37 +173,4 @@ describe('Remote interactions', () => {
});
}
});

it('archives the remote Keys', async () => {
const mockedDate = new Date(
'Sun Dec 10 2017 00:00:00 GMT+0000 (Greenwich Mean Time)'
);
global.Date = jest.fn(() => mockedDate);
const keyValue = {
baseline:
'chrome/default/archive/Sun Dec 10 2017 00:00:00 GMT+0000 (Greenwich Mean Time)/baseline/mock/resolved/path/file1'
};

const config = {
remoteRegion: 'region',
browser: 'chrome',
baseline: './e2eTests/baseline',
latest: './e2eTests/latest',
generatedDiffs: './e2eTests/generatedDiffs',
branch: 'default'
};
const file = ['file1'];
fs.readdirSync.mockReturnValue(file);
fs.createReadStream.mockReturnValue({
on: () => {}
});
for (const [key, value] of Object.entries(keyValue)) {
await archiveRemoteKeys(key, config)
.then(promises => promises[0])
.then(obj => obj.Key)
.then(name => {
expect(name).toEqual(value);
});
}
});
});
4 changes: 3 additions & 1 deletion src/snapshotter.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ export default class SnapShotter {
console.log(''); // eslint-disable-line no-console // space for progress bar
logger.error(
'snapshotter',
`❌ Unable to find the specified waitForIFrameElement element on the page! ❌ ${error}`
`❌ Unable to find the specified waitForIFrameElement element on the page for ${
this._label
}${error}`
);
} finally {
await this.driver.switchTo().defaultContent();
Expand Down

0 comments on commit e25bb8e

Please sign in to comment.