Skip to content

Commit c82b749

Browse files
committed
Prettier tests
1 parent 994f8bc commit c82b749

File tree

2 files changed

+46
-20
lines changed

2 files changed

+46
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"homepage": "https://github.com/mapbox/maki",
4141
"husky": {
4242
"hooks": {
43-
"pre-commit": "eslint ./scripts/* && npm run build && prettier --write ./scripts/* ./browser.* && git add ."
43+
"pre-commit": "eslint ./scripts/* && npm run build && prettier --write ./scripts/* ./browser.* ./test/* && git add ."
4444
}
4545
},
4646
"prettier": {

test/maki.test.js

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,7 @@ test('valid svgs ', function(t) {
110110
});
111111
}
112112

113-
if (
114-
!(height === 15) ||
115-
!(width === 15) ||
116-
height !== width
117-
)
113+
if (!(height === 15) || !(width === 15) || height !== width)
118114
errors.push('invalid size');
119115

120116
if (
@@ -159,23 +155,53 @@ test('valid svgs with meta', async function(t) {
159155
const fileNames = await readdir(iconPath);
160156

161157
fileNames
162-
.filter(f => f.split('.').pop().indexOf('svg') !== -1)
158+
.filter(
159+
f =>
160+
f
161+
.split('.')
162+
.pop()
163+
.indexOf('svg') !== -1
164+
)
163165
.forEach(async f => {
164166
const file = await readFile(path.join(iconPath, f), 'utf8');
165167
const data = await pParse(file);
166-
t.equal(data.svg.$['xmlns:m'], 'https://www.mapbox.com', `xmlns:m is correct`);
167-
168-
const metadataAttributes = [{
169-
'm:parameters':[
170-
{'m:parameter':[
171-
{'$': {"m:name":"background","m:type":"color","m:value":"#000"}},
172-
{'$':{"m:name":"stroke","m:type":"color","m:value":"#fff"}
173-
}]
174-
}]
175-
}]
176-
177-
t.deepEqual(data.svg['m:metadata'], metadataAttributes, `metadata is correct`);
178-
});
168+
t.equal(
169+
data.svg.$['xmlns:m'],
170+
'https://www.mapbox.com',
171+
`xmlns:m is correct`
172+
);
173+
174+
const metadataAttributes = [
175+
{
176+
'm:parameters': [
177+
{
178+
'm:parameter': [
179+
{
180+
$: {
181+
'm:name': 'background',
182+
'm:type': 'color',
183+
'm:value': '#000'
184+
}
185+
},
186+
{
187+
$: {
188+
'm:name': 'stroke',
189+
'm:type': 'color',
190+
'm:value': '#fff'
191+
}
192+
}
193+
]
194+
}
195+
]
196+
}
197+
];
198+
199+
t.deepEqual(
200+
data.svg['m:metadata'],
201+
metadataAttributes,
202+
`metadata is correct`
203+
);
204+
});
179205

180206
t.end();
181207
});

0 commit comments

Comments
 (0)