forked from nodejs/i18n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
46 lines (40 loc) · 1.65 KB
/
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
const fs = require('fs')
const path = require('path')
const walk = require('walk-sync').entries
const {nodeVersions} = require('./package.json')
const semver = require('semver')
const contentDir = path.join(__dirname, 'content')
test('defines nodeVersions', () => {
const majors = Object.keys(nodeVersions)
const expectedMajors = ['v10.x', 'v8.x', 'v6.x']
expect(expectedMajors).toEqual(majors)
const versions = Object.values(nodeVersions)
expect(versions.every(semver.valid)).toBe(true)
expect(versions.every(version => version.startsWith('v'))).toBe(true)
})
test('includes source English content for all major versions', () => {
const fetchedMajors = fs.readdirSync(contentDir).sort()
const targetMajors = Object.keys(nodeVersions).sort()
expect(targetMajors).toEqual(fetchedMajors)
fetchedMajors.forEach(major => {
const languages = fs.readdirSync(path.join(contentDir, major))
expect(languages.includes('en-US')).toBe(true)
})
})
xtest('includes translated content for all major versions', () => {
// pending Crowdin integration
})
test('includes only markdown files, ignoring images and other files', () => {
const versions = fs.readdirSync(contentDir)
expect(versions.length).toBeGreaterThan(1)
versions.forEach(version => {
const languages = fs.readdirSync(path.join(contentDir, version))
expect(languages.length).toBeGreaterThan(0)
languages.forEach(language => {
const docsDir = path.join(contentDir, version, language, 'doc')
const files = walk(docsDir, {directories: false})
expect(files.length).toBeGreaterThan(60)
expect(files.every(file => file.relativePath.endsWith('.md')))
})
})
})