mirror of
https://github.com/simple-icons/simple-icons.git
synced 2024-11-16 00:59:07 +02:00
switch from uvu to mocha (#7071)
* switch from uvu to mocha * remove unused import * custom min reporter * use constants
This commit is contained in:
parent
cc649017cc
commit
d49492f1ef
@ -37,6 +37,7 @@
|
||||
"husky": "7.0.4",
|
||||
"is-ci": "3.0.1",
|
||||
"jsonschema": "1.4.0",
|
||||
"mocha": "9.1.4",
|
||||
"named-html-entities-json": "1.0.0",
|
||||
"npm-run-all": "4.1.5",
|
||||
"prettier": "2.5.1",
|
||||
@ -45,8 +46,7 @@
|
||||
"svg-path-segments": "1.0.0",
|
||||
"svglint": "2.0.0",
|
||||
"svgo": "2.8.0",
|
||||
"svgpath": "2.4.0",
|
||||
"uvu": "0.5.2"
|
||||
"svgpath": "2.4.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node scripts/build/package.js",
|
||||
@ -61,7 +61,7 @@
|
||||
"prepare": "is-ci || husky install",
|
||||
"prepublishOnly": "npm run build",
|
||||
"postpublish": "npm run clean",
|
||||
"test": "uvu",
|
||||
"test": "mocha tests --reporter tests/min-reporter.cjs --inline-diffs",
|
||||
"pretest": "npm run prepublishOnly",
|
||||
"posttest": "npm run postpublish",
|
||||
"svgo": "svgo --config svgo.config.js",
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { exec } from 'uvu';
|
||||
import { testIcon } from './test-icon.js';
|
||||
import { getIconSlug, getIconsData } from '../scripts/utils.js';
|
||||
(async () => {
|
||||
@ -14,6 +13,4 @@ import { getIconSlug, getIconsData } from '../scripts/utils.js';
|
||||
});
|
||||
|
||||
await Promise.all(tests);
|
||||
|
||||
exec();
|
||||
})();
|
||||
|
@ -5,7 +5,6 @@ import {
|
||||
} from '../scripts/utils.js';
|
||||
import * as simpleIcons from '../icons.mjs';
|
||||
import { testIcon } from './test-icon.js';
|
||||
import { exec } from 'uvu';
|
||||
|
||||
(async () => {
|
||||
const icons = await getIconsData();
|
||||
@ -17,6 +16,4 @@ import { exec } from 'uvu';
|
||||
|
||||
testIcon(icon, subject, slug);
|
||||
});
|
||||
|
||||
exec();
|
||||
})();
|
||||
|
@ -1,7 +1,7 @@
|
||||
import simpleIcons from '../index.js';
|
||||
import { getIconSlug, getIconsData } from '../scripts/utils.js';
|
||||
import { test, exec } from 'uvu';
|
||||
import * as assert from 'uvu/assert';
|
||||
import { test } from 'mocha';
|
||||
import { strict as assert } from 'node:assert';
|
||||
|
||||
(async () => {
|
||||
const icons = await getIconsData();
|
||||
@ -12,9 +12,9 @@ import * as assert from 'uvu/assert';
|
||||
test(`'Get' ${icon.title} by its slug`, () => {
|
||||
const found = simpleIcons.Get(slug);
|
||||
assert.ok(found);
|
||||
assert.is(found.title, icon.title);
|
||||
assert.is(found.hex, icon.hex);
|
||||
assert.is(found.source, icon.source);
|
||||
assert.equal(found.title, icon.title);
|
||||
assert.equal(found.hex, icon.hex);
|
||||
assert.equal(found.source, icon.source);
|
||||
});
|
||||
});
|
||||
|
||||
@ -22,11 +22,7 @@ import * as assert from 'uvu/assert';
|
||||
const iconArray = Object.values(simpleIcons);
|
||||
for (let icon of iconArray) {
|
||||
assert.ok(icon);
|
||||
assert.type(icon, 'object');
|
||||
assert.equal(typeof icon, 'object');
|
||||
}
|
||||
});
|
||||
|
||||
test.run();
|
||||
|
||||
exec();
|
||||
})();
|
||||
|
12
tests/min-reporter.cjs
Normal file
12
tests/min-reporter.cjs
Normal file
@ -0,0 +1,12 @@
|
||||
const { reporters, Runner } = require('mocha');
|
||||
|
||||
const { EVENT_RUN_END } = Runner.constants;
|
||||
|
||||
class EvenMoreMin extends reporters.Base {
|
||||
constructor(runner) {
|
||||
super(runner);
|
||||
runner.once(EVENT_RUN_END, () => this.epilogue());
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = EvenMoreMin;
|
@ -1,8 +1,8 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { test } from 'uvu';
|
||||
import * as assert from 'uvu/assert';
|
||||
import { test } from 'mocha';
|
||||
import { strict as assert } from 'node:assert';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const root = path.dirname(__dirname);
|
||||
@ -39,6 +39,4 @@ for (let whiteIconFileName of whiteIconsFileNames) {
|
||||
blackIconContent.replace('<svg', '<svg fill="white"'),
|
||||
);
|
||||
});
|
||||
|
||||
test.run();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { suite } from 'uvu';
|
||||
import * as assert from 'uvu/assert';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import { describe, it } from 'mocha';
|
||||
|
||||
const iconsDir = path.resolve(process.cwd(), 'icons');
|
||||
|
||||
@ -12,60 +12,59 @@ const iconsDir = path.resolve(process.cwd(), 'icons');
|
||||
* @param {String} slug Icon data slug
|
||||
*/
|
||||
export const testIcon = (icon, subject, slug) => {
|
||||
const test = suite(icon.title);
|
||||
const svgPath = path.resolve(iconsDir, `${slug}.svg`);
|
||||
|
||||
test('has the correct "title"', () => {
|
||||
assert.is(subject.title, icon.title);
|
||||
});
|
||||
describe(icon.title, () => {
|
||||
it('has the correct "title"', () => {
|
||||
assert.equal(subject.title, icon.title);
|
||||
});
|
||||
|
||||
test('has the correct "slug"', () => {
|
||||
assert.is(subject.slug, slug);
|
||||
});
|
||||
it('has the correct "slug"', () => {
|
||||
assert.equal(subject.slug, slug);
|
||||
});
|
||||
|
||||
test('has the correct "hex" value', () => {
|
||||
assert.is(subject.hex, icon.hex);
|
||||
});
|
||||
it('has the correct "hex" value', () => {
|
||||
assert.equal(subject.hex, icon.hex);
|
||||
});
|
||||
|
||||
test('has the correct "source"', () => {
|
||||
assert.is(subject.source, icon.source);
|
||||
});
|
||||
it('has the correct "source"', () => {
|
||||
assert.equal(subject.source, icon.source);
|
||||
});
|
||||
|
||||
test('has an "svg" value', () => {
|
||||
assert.type(subject.svg, 'string');
|
||||
});
|
||||
it('has an "svg" value', () => {
|
||||
assert.equal(typeof subject.svg, 'string');
|
||||
});
|
||||
|
||||
test('has a valid "path" value', () => {
|
||||
assert.match(subject.path, /^[MmZzLlHhVvCcSsQqTtAaEe0-9-,.\s]+$/g);
|
||||
});
|
||||
it('has a valid "path" value', () => {
|
||||
assert.match(subject.path, /^[MmZzLlHhVvCcSsQqTtAaEe0-9-,.\s]+$/g);
|
||||
});
|
||||
|
||||
test(`has ${icon.guidelines ? 'the correct' : 'no'} "guidelines"`, () => {
|
||||
if (icon.guidelines) {
|
||||
assert.is(subject.guidelines, icon.guidelines);
|
||||
} else {
|
||||
assert.is(subject.guidelines, undefined);
|
||||
}
|
||||
});
|
||||
|
||||
test(`has ${icon.license ? 'the correct' : 'no'} "license"`, () => {
|
||||
if (icon.license) {
|
||||
assert.is(subject.license.type, icon.license.type);
|
||||
if (icon.license.type === 'custom') {
|
||||
assert.is(subject.license.url, icon.license.url);
|
||||
it(`has ${icon.guidelines ? 'the correct' : 'no'} "guidelines"`, () => {
|
||||
if (icon.guidelines) {
|
||||
assert.equal(subject.guidelines, icon.guidelines);
|
||||
} else {
|
||||
assert.match(subject.license.url, /^https?:\/\/[^\s]+$/);
|
||||
assert.equal(subject.guidelines, undefined);
|
||||
}
|
||||
} else {
|
||||
assert.is(subject.license, undefined);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('has a valid svg value', () => {
|
||||
const svgFileContents = fs
|
||||
.readFileSync(svgPath, 'utf8')
|
||||
.replace(/\r?\n/, '');
|
||||
assert.is(subject.svg, svgFileContents);
|
||||
});
|
||||
it(`has ${icon.license ? 'the correct' : 'no'} "license"`, () => {
|
||||
if (icon.license) {
|
||||
assert.equal(subject.license.type, icon.license.type);
|
||||
if (icon.license.type === 'custom') {
|
||||
assert.equal(subject.license.url, icon.license.url);
|
||||
} else {
|
||||
assert.match(subject.license.url, /^https?:\/\/[^\s]+$/);
|
||||
}
|
||||
} else {
|
||||
assert.equal(subject.license, undefined);
|
||||
}
|
||||
});
|
||||
|
||||
test.run();
|
||||
it('has a valid svg value', () => {
|
||||
const svgFileContents = fs
|
||||
.readFileSync(svgPath, 'utf8')
|
||||
.replace(/\r?\n/, '');
|
||||
assert.equal(subject.svg, svgFileContents);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user