forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getChallenges.acceptance.test.js
80 lines (76 loc) · 2.6 KB
/
getChallenges.acceptance.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* global expect */
const path = require('path');
const { parseMarkdown } = require('../tools/challenge-md-parser');
const { parseTranslation } = require('./getChallenges');
/* eslint-disable max-len */
const {
SIMPLE_TRANSLATION
} = require('../tools/challenge-md-parser/translation-parser/__mocks__/mock-comments');
/* eslint-enable max-len */
describe('translation parser', () => {
it('should combine to the correct object', () => {
return Promise.all([
parseMarkdown(path.resolve(__dirname, '__fixtures__/combined.md')),
parseTranslation(
path.resolve(__dirname, '__fixtures__/challenge.english.md'),
path.resolve(__dirname, '__fixtures__/challenge.chinese.md'),
SIMPLE_TRANSLATION
)
]).then(xs => expect(xs[1]).toEqual(xs[0]));
});
it('should translate known comments in html', () => {
return Promise.all([
parseMarkdown(
path.resolve(__dirname, '__fixtures__/combined-html-comments.md')
),
parseTranslation(
path.resolve(
__dirname,
'__fixtures__/challenge-html-comments.english.md'
),
path.resolve(__dirname, '__fixtures__/challenge.chinese.md'),
SIMPLE_TRANSLATION
)
]).then(xs => expect(xs[1]).toEqual(xs[0]));
});
it('should translate known comments in jsx', () => {
return Promise.all([
parseMarkdown(
path.resolve(__dirname, '__fixtures__/combined-jsx-comments.md')
),
parseTranslation(
path.resolve(
__dirname,
'__fixtures__/challenge-jsx-comments.english.md'
),
path.resolve(__dirname, '__fixtures__/challenge.chinese.md'),
SIMPLE_TRANSLATION
)
]).then(xs => expect(xs[1]).toEqual(xs[0]));
});
it('should translate known comments in js', () => {
return Promise.all([
parseMarkdown(
path.resolve(__dirname, '__fixtures__/combined-js-comments.md')
),
parseTranslation(
path.resolve(
__dirname,
'__fixtures__/challenge-js-comments.english.md'
),
path.resolve(__dirname, '__fixtures__/challenge.chinese.md'),
SIMPLE_TRANSLATION
)
]).then(xs => expect(xs[1]).toEqual(xs[0]));
});
it('should handle a stripped down challenge', () => {
return Promise.all([
parseMarkdown(path.resolve(__dirname, '__fixtures__/combined.md')),
parseTranslation(
path.resolve(__dirname, '__fixtures__/challenge.english.md'),
path.resolve(__dirname, '__fixtures__/challenge-stripped.chinese.md'),
SIMPLE_TRANSLATION
)
]).then(xs => expect(xs[1]).toEqual(xs[0]));
});
});