mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-30 12:05:39 -05:00
23 lines
713 B
TypeScript
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);
|
|
}
|
|
});
|
|
});
|