mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-08 22:03:01 +02:00
refactor(docs,blog): last update timestamp should be in milliseconds instead of seconds (#9963)
This commit is contained in:
parent
6c724ed857
commit
465cf4d82c
8 changed files with 35 additions and 29 deletions
|
@ -52,13 +52,13 @@ describe('getFileCommitDate', () => {
|
|||
getFileCommitDate(path.join(repoDir, 'test.txt'), {}),
|
||||
).resolves.toEqual({
|
||||
date: new Date('2020-06-19'),
|
||||
timestamp: new Date('2020-06-19').getTime() / 1000,
|
||||
timestamp: new Date('2020-06-19').getTime(),
|
||||
});
|
||||
await expect(
|
||||
getFileCommitDate(path.join(repoDir, 'dest.txt'), {}),
|
||||
).resolves.toEqual({
|
||||
date: new Date('2020-09-13'),
|
||||
timestamp: new Date('2020-09-13').getTime() / 1000,
|
||||
timestamp: new Date('2020-09-13').getTime(),
|
||||
});
|
||||
});
|
||||
it('returns latest commit date', async () => {
|
||||
|
@ -66,13 +66,13 @@ describe('getFileCommitDate', () => {
|
|||
getFileCommitDate(path.join(repoDir, 'test.txt'), {age: 'newest'}),
|
||||
).resolves.toEqual({
|
||||
date: new Date('2020-09-13'),
|
||||
timestamp: new Date('2020-09-13').getTime() / 1000,
|
||||
timestamp: new Date('2020-09-13').getTime(),
|
||||
});
|
||||
await expect(
|
||||
getFileCommitDate(path.join(repoDir, 'dest.txt'), {age: 'newest'}),
|
||||
).resolves.toEqual({
|
||||
date: new Date('2020-11-13'),
|
||||
timestamp: new Date('2020-11-13').getTime() / 1000,
|
||||
timestamp: new Date('2020-11-13').getTime(),
|
||||
});
|
||||
});
|
||||
it('returns latest commit date with author', async () => {
|
||||
|
@ -83,7 +83,7 @@ describe('getFileCommitDate', () => {
|
|||
}),
|
||||
).resolves.toEqual({
|
||||
date: new Date('2020-06-19'),
|
||||
timestamp: new Date('2020-06-19').getTime() / 1000,
|
||||
timestamp: new Date('2020-06-19').getTime(),
|
||||
author: 'Caroline',
|
||||
});
|
||||
await expect(
|
||||
|
@ -93,7 +93,7 @@ describe('getFileCommitDate', () => {
|
|||
}),
|
||||
).resolves.toEqual({
|
||||
date: new Date('2020-09-13'),
|
||||
timestamp: new Date('2020-09-13').getTime() / 1000,
|
||||
timestamp: new Date('2020-09-13').getTime(),
|
||||
author: 'Caroline',
|
||||
});
|
||||
});
|
||||
|
@ -105,7 +105,7 @@ describe('getFileCommitDate', () => {
|
|||
}),
|
||||
).resolves.toEqual({
|
||||
date: new Date('2020-09-13'),
|
||||
timestamp: new Date('2020-09-13').getTime() / 1000,
|
||||
timestamp: new Date('2020-09-13').getTime(),
|
||||
author: 'Caroline',
|
||||
});
|
||||
await expect(
|
||||
|
@ -115,7 +115,7 @@ describe('getFileCommitDate', () => {
|
|||
}),
|
||||
).resolves.toEqual({
|
||||
date: new Date('2020-11-13'),
|
||||
timestamp: new Date('2020-11-13').getTime() / 1000,
|
||||
timestamp: new Date('2020-11-13').getTime(),
|
||||
author: 'Josh-Cena',
|
||||
});
|
||||
});
|
||||
|
|
|
@ -103,7 +103,7 @@ describe('getFileLastUpdate', () => {
|
|||
|
||||
describe('readLastUpdateData', () => {
|
||||
const testDate = '2021-01-01';
|
||||
const testDateTime = new Date(testDate).getTime() / 1000;
|
||||
const testTimestamp = new Date(testDate).getTime();
|
||||
const testAuthor = 'ozaki';
|
||||
|
||||
it('read last time show author time', async () => {
|
||||
|
@ -112,7 +112,7 @@ describe('readLastUpdateData', () => {
|
|||
{showLastUpdateAuthor: true, showLastUpdateTime: true},
|
||||
{date: testDate},
|
||||
);
|
||||
expect(lastUpdatedAt).toEqual(testDateTime);
|
||||
expect(lastUpdatedAt).toEqual(testTimestamp);
|
||||
expect(lastUpdatedBy).toBe(GIT_FALLBACK_LAST_UPDATE_AUTHOR);
|
||||
});
|
||||
|
||||
|
@ -133,7 +133,7 @@ describe('readLastUpdateData', () => {
|
|||
{author: testAuthor, date: testDate},
|
||||
);
|
||||
expect(lastUpdatedBy).toEqual(testAuthor);
|
||||
expect(lastUpdatedAt).toEqual(testDateTime);
|
||||
expect(lastUpdatedAt).toEqual(testTimestamp);
|
||||
});
|
||||
|
||||
it('read last default show none', async () => {
|
||||
|
@ -191,7 +191,7 @@ describe('readLastUpdateData', () => {
|
|||
{date: testDate},
|
||||
);
|
||||
expect(lastUpdatedBy).toBeUndefined();
|
||||
expect(lastUpdatedAt).toEqual(testDateTime);
|
||||
expect(lastUpdatedAt).toEqual(testTimestamp);
|
||||
});
|
||||
|
||||
it('read last author show time', async () => {
|
||||
|
@ -211,7 +211,7 @@ describe('readLastUpdateData', () => {
|
|||
{author: testAuthor, date: testDate},
|
||||
);
|
||||
expect(lastUpdatedBy).toBeUndefined();
|
||||
expect(lastUpdatedAt).toEqual(testDateTime);
|
||||
expect(lastUpdatedAt).toEqual(testTimestamp);
|
||||
});
|
||||
|
||||
it('read last author show author only - both front matter', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue