-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbasic.js
120 lines (105 loc) · 2.5 KB
/
basic.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const test = require('tape')
const { existsSync, readFileSync } = require('fs')
const { join, relative } = require('path')
const ROOT_PATH = join(__dirname, '..')
const SRC_PATH = join(ROOT_PATH, 'src')
test('Check that src/ looks reasonable', t => {
const paths = [
'learnyouhtml',
'javascripting',
'learnyounode'
]
paths
.map(path => join(SRC_PATH, path))
.forEach(path => assertExists(t, path))
t.end()
})
test('Check that src/learnyouhtml looks reasonable', t => {
const paths = [
'index.html',
'tags.html',
'attributes.html',
'inline-tags.html',
'headings.html',
'lists.html',
'tables.html',
'blocks.html',
'links-and-references.html',
'forms.html',
'styles-and-scripts.html'
]
paths
.map(path => join(SRC_PATH, 'learnyouhtml', path))
.forEach(path => {
assertExists(t, path)
assertNoTodo(t, path)
})
t.end()
})
test('Check that src/javascripting looks reasonable', t => {
const paths = [
'introduction.js',
'variables.js',
'strings.js',
'string-length.js',
'revising-strings.js',
'numbers.js',
'rounding-numbers.js',
'number-to-string.js',
'if-statement.js',
'for-loop.js',
'arrays.js',
'array-filtering.js',
'accessing-array-values.js',
'looping-through-arrays.js',
'objects.js',
'object-properties.js',
'object-keys.js',
'functions.js',
'function-arguments.js',
'scope.js'
]
paths
.map(path => join(SRC_PATH, 'javascripting', path))
.forEach(path => {
assertExists(t, path)
assertNoTodo(t, path)
})
t.end()
})
test('Check that src/learnyounode looks reasonable', t => {
const paths = [
'hello-world.js',
'baby-steps.js',
'my-first-io.js',
'my-first-async-io.js',
'filtered-ls.js',
'make-it-modular.js',
'mymodule.js',
'http-client.js',
'http-collect.js',
'juggling-async.js',
'time-server.js',
'http-file-server.js',
'http-uppercaserer.js',
'http-json-api-server.js'
]
paths
.map(path => join(SRC_PATH, 'learnyounode', path))
.forEach(path => {
assertExists(t, path)
assertNoTodo(t, path)
})
t.end()
})
function assertExists (t, path) {
const relPath = relative(ROOT_PATH, path)
t.ok(existsSync(path), `ensure ${relPath} exists`)
}
function assertNoTodo (t, path) {
const relPath = relative(ROOT_PATH, path)
t.ok(
!readFileSync(path, 'utf8').includes('TODO'),
`ensure ${relPath} does not contain the string "TODO"`
)
}