test: add certificate specific tests
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
fa931134a4
commit
d41e44ebf9
@ -1,3 +1,30 @@
|
||||
const ENGLISH_CERTIFICATE = {
|
||||
id: '561add10cb82ac38a17513bc',
|
||||
title: 'Responsive Web Design Certificate',
|
||||
challengeType: 7,
|
||||
isPrivate: true,
|
||||
tests: [
|
||||
{ id: 'bd7158d8c442eddfaeb5bd18', title: 'Build a Tribute Page' },
|
||||
{ id: '587d78af367417b2b2512b03', title: 'Build a Survey Form' },
|
||||
{
|
||||
id: '587d78af367417b2b2512b04',
|
||||
title: 'Build a Product Landing Page'
|
||||
},
|
||||
{
|
||||
id: '587d78b0367417b2b2512b05',
|
||||
title: 'Build a Technical Documentation Page'
|
||||
},
|
||||
{
|
||||
id: 'bd7158d8c242eddfaeb5bd13',
|
||||
title: 'Build a Personal Portfolio Webpage'
|
||||
}
|
||||
],
|
||||
solutions: ['// solution required\n'],
|
||||
description: '',
|
||||
instructions: '',
|
||||
files: []
|
||||
};
|
||||
|
||||
const ENGLISH_CHALLENGE = {
|
||||
id: 'id',
|
||||
title: 'Title',
|
||||
@ -82,6 +109,35 @@ const ENGLISH_CHALLENGE_NO_FILES = {
|
||||
files: []
|
||||
};
|
||||
|
||||
const TRANSLATED_CERTIFICATE = {
|
||||
id: '561add10cb82ac38a17513bc',
|
||||
title: 'Responsive Web Design Certificate',
|
||||
challengeType: 7,
|
||||
isPrivate: true,
|
||||
videoUrl: '',
|
||||
localeTitle: '响应式网页设计证书',
|
||||
tests: [
|
||||
{ id: 'bd7158d8c442eddfaeb5bd18', title: 'Build a Tribute Page' },
|
||||
{ id: '587d78af367417b2b2512b03', title: 'Build a Survey Form' },
|
||||
{
|
||||
id: '587d78af367417b2b2512b04',
|
||||
title: 'Build a Product Landing Page'
|
||||
},
|
||||
{
|
||||
id: '587d78b0367417b2b2512b05',
|
||||
title: 'Build a Technical Documentation Page'
|
||||
},
|
||||
{
|
||||
id: 'bd7158d8c242eddfaeb5bd13',
|
||||
title: 'Build a Personal Portfolio Webpage'
|
||||
}
|
||||
],
|
||||
solutions: ['// solution required\n'],
|
||||
description: '',
|
||||
instructions: '',
|
||||
files: []
|
||||
};
|
||||
|
||||
const TRANSLATED_CHALLENGE = {
|
||||
id: 'id',
|
||||
title: 'Title',
|
||||
@ -142,8 +198,10 @@ const WRONG_NUM_TESTS_CHALLENGE = {
|
||||
]
|
||||
};
|
||||
|
||||
exports.ENGLISH_CERTIFICATE = ENGLISH_CERTIFICATE;
|
||||
exports.ENGLISH_CHALLENGE = ENGLISH_CHALLENGE;
|
||||
exports.ENGLISH_CHALLENGE_TWO_SOLUTIONS = ENGLISH_CHALLENGE_TWO_SOLUTIONS;
|
||||
exports.ENGLISH_CHALLENGE_NO_FILES = ENGLISH_CHALLENGE_NO_FILES;
|
||||
exports.TRANSLATED_CERTIFICATE = TRANSLATED_CERTIFICATE;
|
||||
exports.TRANSLATED_CHALLENGE = TRANSLATED_CHALLENGE;
|
||||
exports.WRONG_NUM_TESTS_CHALLENGE = WRONG_NUM_TESTS_CHALLENGE;
|
||||
|
@ -5,9 +5,11 @@ const {
|
||||
translateCommentsInChallenge
|
||||
} = require('./translation-parser');
|
||||
const {
|
||||
ENGLISH_CERTIFICATE,
|
||||
ENGLISH_CHALLENGE,
|
||||
ENGLISH_CHALLENGE_NO_FILES,
|
||||
ENGLISH_CHALLENGE_TWO_SOLUTIONS,
|
||||
TRANSLATED_CERTIFICATE,
|
||||
TRANSLATED_CHALLENGE,
|
||||
WRONG_NUM_TESTS_CHALLENGE
|
||||
} = require('./__fixtures__/challenge-objects');
|
||||
@ -22,6 +24,12 @@ const COMBINED_CHALLENGE_TWO_SOLUTIONS = mergeChallenges(
|
||||
ENGLISH_CHALLENGE_TWO_SOLUTIONS,
|
||||
TRANSLATED_CHALLENGE
|
||||
);
|
||||
|
||||
const COMBINED_CERTIFICATE = mergeChallenges(
|
||||
ENGLISH_CERTIFICATE,
|
||||
TRANSLATED_CERTIFICATE
|
||||
);
|
||||
|
||||
let logSpy;
|
||||
|
||||
describe('translation parser', () => {
|
||||
@ -100,6 +108,28 @@ describe('translation parser', () => {
|
||||
TRANSLATED_CHALLENGE.forumTopicId
|
||||
);
|
||||
});
|
||||
it('takes the ids from the first certificate', () => {
|
||||
const actualIds = COMBINED_CERTIFICATE.tests.map(({ id }) => id);
|
||||
const expectedIds = ENGLISH_CERTIFICATE.tests.map(({ id }) => id);
|
||||
for (let i = 0; i < actualIds.length; i++) {
|
||||
expect(actualIds[i]).toBe(expectedIds[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it('takes the titles from the second certificate', () => {
|
||||
const actualTitles = COMBINED_CERTIFICATE.tests.map(({ title }) => title);
|
||||
const expectedTitles = TRANSLATED_CERTIFICATE.tests.map(
|
||||
({ title }) => title
|
||||
);
|
||||
for (let i = 0; i < actualTitles.length; i++) {
|
||||
expect(actualTitles[i]).toBe(expectedTitles[i]);
|
||||
}
|
||||
});
|
||||
it('certificates do not have a forumTopicId property', () => {
|
||||
expect(Object.keys(COMBINED_CERTIFICATE).includes('forumTopicId')).toBe(
|
||||
false
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('translateCommentsInChallenge', () => {
|
||||
|
Reference in New Issue
Block a user