Skip to content

Commit

Permalink
Prettier tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tristen committed Jan 3, 2025
1 parent 994f8bc commit c82b749
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"homepage": "https://github.com/mapbox/maki",
"husky": {
"hooks": {
"pre-commit": "eslint ./scripts/* && npm run build && prettier --write ./scripts/* ./browser.* && git add ."
"pre-commit": "eslint ./scripts/* && npm run build && prettier --write ./scripts/* ./browser.* ./test/* && git add ."
}
},
"prettier": {
Expand Down
64 changes: 45 additions & 19 deletions test/maki.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ test('valid svgs ', function(t) {
});
}

if (
!(height === 15) ||
!(width === 15) ||
height !== width
)
if (!(height === 15) || !(width === 15) || height !== width)
errors.push('invalid size');

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

fileNames
.filter(f => f.split('.').pop().indexOf('svg') !== -1)
.filter(
f =>
f
.split('.')
.pop()
.indexOf('svg') !== -1
)
.forEach(async f => {
const file = await readFile(path.join(iconPath, f), 'utf8');
const data = await pParse(file);
t.equal(data.svg.$['xmlns:m'], 'https://www.mapbox.com', `xmlns:m is correct`);

const metadataAttributes = [{
'm:parameters':[
{'m:parameter':[
{'$': {"m:name":"background","m:type":"color","m:value":"#000"}},
{'$':{"m:name":"stroke","m:type":"color","m:value":"#fff"}
}]
}]
}]

t.deepEqual(data.svg['m:metadata'], metadataAttributes, `metadata is correct`);
});
t.equal(
data.svg.$['xmlns:m'],
'https://www.mapbox.com',
`xmlns:m is correct`
);

const metadataAttributes = [
{
'm:parameters': [
{
'm:parameter': [
{
$: {
'm:name': 'background',
'm:type': 'color',
'm:value': '#000'
}
},
{
$: {
'm:name': 'stroke',
'm:type': 'color',
'm:value': '#fff'
}
}
]
}
]
}
];

t.deepEqual(
data.svg['m:metadata'],
metadataAttributes,
`metadata is correct`
);
});

t.end();
});

0 comments on commit c82b749

Please sign in to comment.