mirror of
https://github.com/zhigang1992/yarn.git
synced 2026-06-19 20:01:59 +08:00
a nodejs issue causes certain dates to be off by 1ms after calling utimes See: https://github.com/nodejs/node/pull/12607
53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
/* @flow */
|
|
|
|
import {fileDatesEqual} from '../../src/util/fs.js';
|
|
|
|
describe('fileDatesEqual', () => {
|
|
const realPlatform = process.platform;
|
|
|
|
describe('!win32', () => {
|
|
beforeAll(() => {
|
|
process.platform = 'notWin32';
|
|
});
|
|
|
|
afterAll(() => {
|
|
process.platform = realPlatform;
|
|
});
|
|
|
|
test('Same dates equal', () => {
|
|
expect(fileDatesEqual(new Date(1491393798834), new Date(1491393798834))).toBeTruthy();
|
|
expect(fileDatesEqual(new Date(1491393798000), new Date(1491393798000))).toBeTruthy();
|
|
});
|
|
|
|
test('Different dates differ', () => {
|
|
expect(fileDatesEqual(new Date(1491393798834), new Date(1491393798835))).toBeFalsy();
|
|
expect(fileDatesEqual(new Date(1491393700834), new Date(1491393798834))).toBeFalsy();
|
|
expect(fileDatesEqual(new Date(1491393798000), new Date(1491393798835))).toBeFalsy();
|
|
});
|
|
});
|
|
describe('win32', () => {
|
|
beforeAll(() => {
|
|
process.platform = 'win32';
|
|
});
|
|
|
|
afterAll(() => {
|
|
process.platform = realPlatform;
|
|
});
|
|
|
|
test('Same dates equal', () => {
|
|
expect(fileDatesEqual(new Date(1491393798834), new Date(1491393798834))).toBeTruthy();
|
|
});
|
|
|
|
test('Different dates differ', () => {
|
|
expect(fileDatesEqual(new Date(1491393798834), new Date(1491393798835))).toBeTruthy();
|
|
expect(fileDatesEqual(new Date(1491393798834), new Date(1491393798836))).toBeFalsy();
|
|
expect(fileDatesEqual(new Date(1491393700834), new Date(1491393798834))).toBeFalsy();
|
|
});
|
|
|
|
test('Milliseconds are ignored when one date has zero milliseconds', () => {
|
|
expect(fileDatesEqual(new Date(1491393798000), new Date(1491393798835))).toBeTruthy();
|
|
expect(fileDatesEqual(new Date(1491393798834), new Date(1491393798000))).toBeTruthy();
|
|
});
|
|
});
|
|
});
|