Files
freeCodeCamp/api/src/utils/get-challenges.test.ts
Niraj Nandish 260d64a0ed fix(api): getChallenges helper function (#51011)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2023-07-19 13:10:32 +02:00

23 lines
713 B
TypeScript

import { getChallenges } from './get-challenges';
import { isObjectID } from './validation';
describe('getChallenges', () => {
test('returns an array of challenges', () => {
const challenges = getChallenges();
expect(Array.isArray(challenges)).toBe(true);
expect(challenges.length).toBeGreaterThan(0);
});
test('challenge objects should contain challengeType and id', () => {
const challenges = getChallenges();
for (const challenge of challenges) {
expect(challenge).toHaveProperty('challengeType');
expect(typeof challenge?.challengeType).toBe('number');
expect(challenge).toHaveProperty('id');
expect(isObjectID(challenge?.id)).toBe(true);
}
});
});