-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
187 lines (173 loc) · 5.67 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
'use strict'
var test = require('tape')
var androidIcons = require('./')
var exec = require('child_process').exec
test('returns all icons in array', function (t) {
t.plan(2)
var icons = androidIcons()
t.ok(Array.isArray(icons), 'returned an array')
t.equal(icons.length, 5, '5 icons returned')
})
test('returns icon for size 48 as Number', function (t) {
t.plan(2)
var icon = androidIcons({size: 48})
t.ok(icon.name === 'mdpi.png', 'icon name correct')
t.ok(icon.width === 48, 'icon width correct')
})
test('returns icon for size 48 as String', function (t) {
t.plan(2)
var icon = androidIcons({size: '48'})
t.ok(icon.name === 'mdpi.png', 'icon name correct')
t.ok(icon.width === 48, 'icon width correct')
})
test('returns icon for size 96', function (t) {
t.plan(2)
var icon = androidIcons({size: 96})
t.ok(icon.name === 'xhdpi.png', 'icon name correct')
t.ok(icon.width === 96, 'icon width correct')
})
test('returns icon for size xhdpi', function (t) {
t.plan(2)
var icon = androidIcons({size: 'xhdpi'})
t.ok(icon.name === 'xhdpi.png', 'icon name correct')
t.ok(icon.width === 96, 'icon width correct')
})
test('cli returns all icons as csv', function (t) {
t.plan(1)
var expected = [
'mdpi.png,48',
'hdpi.png,72',
'xhdpi.png,96',
'xxhdpi.png,144',
'xxxhdpi.png,192\n'
].join('\n')
exec('./bin/android-icons.js', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
})
test('cli returns icon for size', function (t) {
t.plan(1)
var expected = 'hdpi.png,72\n'
exec('./bin/android-icons.js --size 72', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
})
test('cli returns icon for size', function (t) {
t.plan(1)
var expected = 'xhdpi.png,96\n'
exec('./bin/android-icons.js --size xhdpi', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
})
test('cli returns all icons as csv', function (t) {
t.plan(1)
var expected = [
'mdpi.png,48',
'hdpi.png,72',
'xhdpi.png,96',
'xxhdpi.png,144',
'xxxhdpi.png,192\n'
].join('\n')
exec('./bin/android-icons.js', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
})
test('cli returns icon for size', function (t) {
t.plan(1)
var expected = 'hdpi.png,72\n'
exec('./bin/android-icons.js --size 72', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
})
test('cli returns icon for size xhdpi', function (t) {
t.plan(1)
var expected = 'xhdpi.png,96\n'
exec('./bin/android-icons.js --size xhdpi', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
})
test('cli returns all icons as json w/abbreviated flags', function (t) {
t.plan(3)
var expected = '[{"name":"mdpi.png","width":48},{"name":"hdpi.png","width":72},{"name":"xhdpi.png","width":96},{"name":"xxhdpi.png","width":144},{"name":"xxxhdpi.png","width":192}]\n'
exec('./bin/android-icons.js --forma json', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
exec('./bin/android-icons.js --for json', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
exec('./bin/android-icons.js --f json', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
})
test('cli returns icon for size w/abbreviated flag', function (t) {
t.plan(3)
var expected = 'hdpi.png,72\n'
exec('./bin/android-icons.js --siz 72', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
exec('./bin/android-icons.js --si 72', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
exec('./bin/android-icons.js --s 72', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
})
test('cli returns icon for size xhdpi w/ abbreviated flag', function (t) {
t.plan(1)
var expected = 'xhdpi.png,96\n'
exec('./bin/android-icons.js --size xhdpi', function (error, stdout, stderr) {
var err = error || stderr
if (err) {
return t.fail('calling cli produced an error: ' + err)
}
t.equal(stdout, expected, 'cli returned expected output')
})
})