Files
freecodecamp--freecodecamp/api/src/routes/helpers/certificate-utils.test.ts
T
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

51 lines
1.2 KiB
TypeScript

import { describe, test, expect } from 'vitest';
import { getFallbackFullStackDate } from './certificate-utils.js';
const fullStackChallenges = [
{
completedDate: 1585210952511,
id: '5a553ca864b52e1d8bceea14'
},
{
completedDate: 1585210952511,
id: '561add10cb82ac38a17513bc'
},
{
completedDate: 1588665778679,
id: '561acd10cb82ac38a17513bc'
},
{
completedDate: 1685210952511,
id: '561abd10cb81ac38a17513bc'
},
{
completedDate: 1585210952511,
id: '561add10cb82ac38a17523bc'
},
{
completedDate: 1588665778679,
id: '561add10cb82ac38a17213bc'
}
];
describe('helper functions', () => {
describe('getFallbackFullStackDate', () => {
test('should return the date of the latest completed challenge', () => {
expect(getFallbackFullStackDate(fullStackChallenges, 123)).toBe(
1685210952511
);
});
test('should fall back to completedDate if no certifications are provided', () => {
expect(getFallbackFullStackDate([], 123)).toBe(123);
});
test('should fall back to completedDate if none of the certifications have been completed', () => {
expect(
getFallbackFullStackDate([{ completedDate: 567, id: 'abc' }], 123)
).toBe(123);
});
});
});