mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-04-07 21:30:16 +03: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",
|
"husky": "7.0.4",
|
||||||
"is-ci": "3.0.1",
|
"is-ci": "3.0.1",
|
||||||
"jsonschema": "1.4.0",
|
"jsonschema": "1.4.0",
|
||||||
|
"mocha": "9.1.4",
|
||||||
"named-html-entities-json": "1.0.0",
|
"named-html-entities-json": "1.0.0",
|
||||||
"npm-run-all": "4.1.5",
|
"npm-run-all": "4.1.5",
|
||||||
"prettier": "2.5.1",
|
"prettier": "2.5.1",
|
||||||
@ -45,8 +46,7 @@
|
|||||||
"svg-path-segments": "1.0.0",
|
"svg-path-segments": "1.0.0",
|
||||||
"svglint": "2.0.0",
|
"svglint": "2.0.0",
|
||||||
"svgo": "2.8.0",
|
"svgo": "2.8.0",
|
||||||
"svgpath": "2.4.0",
|
"svgpath": "2.4.0"
|
||||||
"uvu": "0.5.2"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node scripts/build/package.js",
|
"build": "node scripts/build/package.js",
|
||||||
@ -61,7 +61,7 @@
|
|||||||
"prepare": "is-ci || husky install",
|
"prepare": "is-ci || husky install",
|
||||||
"prepublishOnly": "npm run build",
|
"prepublishOnly": "npm run build",
|
||||||
"postpublish": "npm run clean",
|
"postpublish": "npm run clean",
|
||||||
"test": "uvu",
|
"test": "mocha tests --reporter tests/min-reporter.cjs --inline-diffs",
|
||||||
"pretest": "npm run prepublishOnly",
|
"pretest": "npm run prepublishOnly",
|
||||||
"posttest": "npm run postpublish",
|
"posttest": "npm run postpublish",
|
||||||
"svgo": "svgo --config svgo.config.js",
|
"svgo": "svgo --config svgo.config.js",
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { exec } from 'uvu';
|
|
||||||
import { testIcon } from './test-icon.js';
|
import { testIcon } from './test-icon.js';
|
||||||
import { getIconSlug, getIconsData } from '../scripts/utils.js';
|
import { getIconSlug, getIconsData } from '../scripts/utils.js';
|
||||||
(async () => {
|
(async () => {
|
||||||
@ -14,6 +13,4 @@ import { getIconSlug, getIconsData } from '../scripts/utils.js';
|
|||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all(tests);
|
await Promise.all(tests);
|
||||||
|
|
||||||
exec();
|
|
||||||
})();
|
})();
|
||||||
|
@ -5,7 +5,6 @@ import {
|
|||||||
} from '../scripts/utils.js';
|
} from '../scripts/utils.js';
|
||||||
import * as simpleIcons from '../icons.mjs';
|
import * as simpleIcons from '../icons.mjs';
|
||||||
import { testIcon } from './test-icon.js';
|
import { testIcon } from './test-icon.js';
|
||||||
import { exec } from 'uvu';
|
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const icons = await getIconsData();
|
const icons = await getIconsData();
|
||||||
@ -17,6 +16,4 @@ import { exec } from 'uvu';
|
|||||||
|
|
||||||
testIcon(icon, subject, slug);
|
testIcon(icon, subject, slug);
|
||||||
});
|
});
|
||||||
|
|
||||||
exec();
|
|
||||||
})();
|
})();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import simpleIcons from '../index.js';
|
import simpleIcons from '../index.js';
|
||||||
import { getIconSlug, getIconsData } from '../scripts/utils.js';
|
import { getIconSlug, getIconsData } from '../scripts/utils.js';
|
||||||
import { test, exec } from 'uvu';
|
import { test } from 'mocha';
|
||||||
import * as assert from 'uvu/assert';
|
import { strict as assert } from 'node:assert';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const icons = await getIconsData();
|
const icons = await getIconsData();
|
||||||
@ -12,9 +12,9 @@ import * as assert from 'uvu/assert';
|
|||||||
test(`'Get' ${icon.title} by its slug`, () => {
|
test(`'Get' ${icon.title} by its slug`, () => {
|
||||||
const found = simpleIcons.Get(slug);
|
const found = simpleIcons.Get(slug);
|
||||||
assert.ok(found);
|
assert.ok(found);
|
||||||
assert.is(found.title, icon.title);
|
assert.equal(found.title, icon.title);
|
||||||
assert.is(found.hex, icon.hex);
|
assert.equal(found.hex, icon.hex);
|
||||||
assert.is(found.source, icon.source);
|
assert.equal(found.source, icon.source);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -22,11 +22,7 @@ import * as assert from 'uvu/assert';
|
|||||||
const iconArray = Object.values(simpleIcons);
|
const iconArray = Object.values(simpleIcons);
|
||||||
for (let icon of iconArray) {
|
for (let icon of iconArray) {
|
||||||
assert.ok(icon);
|
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 fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { test } from 'uvu';
|
import { test } from 'mocha';
|
||||||
import * as assert from 'uvu/assert';
|
import { strict as assert } from 'node:assert';
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
const root = path.dirname(__dirname);
|
const root = path.dirname(__dirname);
|
||||||
@ -39,6 +39,4 @@ for (let whiteIconFileName of whiteIconsFileNames) {
|
|||||||
blackIconContent.replace('<svg', '<svg fill="white"'),
|
blackIconContent.replace('<svg', '<svg fill="white"'),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.run();
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { suite } from 'uvu';
|
import { strict as assert } from 'node:assert';
|
||||||
import * as assert from 'uvu/assert';
|
import { describe, it } from 'mocha';
|
||||||
|
|
||||||
const iconsDir = path.resolve(process.cwd(), 'icons');
|
const iconsDir = path.resolve(process.cwd(), 'icons');
|
||||||
|
|
||||||
@ -12,60 +12,59 @@ const iconsDir = path.resolve(process.cwd(), 'icons');
|
|||||||
* @param {String} slug Icon data slug
|
* @param {String} slug Icon data slug
|
||||||
*/
|
*/
|
||||||
export const testIcon = (icon, subject, slug) => {
|
export const testIcon = (icon, subject, slug) => {
|
||||||
const test = suite(icon.title);
|
|
||||||
const svgPath = path.resolve(iconsDir, `${slug}.svg`);
|
const svgPath = path.resolve(iconsDir, `${slug}.svg`);
|
||||||
|
|
||||||
test('has the correct "title"', () => {
|
describe(icon.title, () => {
|
||||||
assert.is(subject.title, icon.title);
|
it('has the correct "title"', () => {
|
||||||
});
|
assert.equal(subject.title, icon.title);
|
||||||
|
});
|
||||||
|
|
||||||
test('has the correct "slug"', () => {
|
it('has the correct "slug"', () => {
|
||||||
assert.is(subject.slug, slug);
|
assert.equal(subject.slug, slug);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('has the correct "hex" value', () => {
|
it('has the correct "hex" value', () => {
|
||||||
assert.is(subject.hex, icon.hex);
|
assert.equal(subject.hex, icon.hex);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('has the correct "source"', () => {
|
it('has the correct "source"', () => {
|
||||||
assert.is(subject.source, icon.source);
|
assert.equal(subject.source, icon.source);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('has an "svg" value', () => {
|
it('has an "svg" value', () => {
|
||||||
assert.type(subject.svg, 'string');
|
assert.equal(typeof subject.svg, 'string');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('has a valid "path" value', () => {
|
it('has a valid "path" value', () => {
|
||||||
assert.match(subject.path, /^[MmZzLlHhVvCcSsQqTtAaEe0-9-,.\s]+$/g);
|
assert.match(subject.path, /^[MmZzLlHhVvCcSsQqTtAaEe0-9-,.\s]+$/g);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(`has ${icon.guidelines ? 'the correct' : 'no'} "guidelines"`, () => {
|
it(`has ${icon.guidelines ? 'the correct' : 'no'} "guidelines"`, () => {
|
||||||
if (icon.guidelines) {
|
if (icon.guidelines) {
|
||||||
assert.is(subject.guidelines, icon.guidelines);
|
assert.equal(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);
|
|
||||||
} else {
|
} 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', () => {
|
it(`has ${icon.license ? 'the correct' : 'no'} "license"`, () => {
|
||||||
const svgFileContents = fs
|
if (icon.license) {
|
||||||
.readFileSync(svgPath, 'utf8')
|
assert.equal(subject.license.type, icon.license.type);
|
||||||
.replace(/\r?\n/, '');
|
if (icon.license.type === 'custom') {
|
||||||
assert.is(subject.svg, svgFileContents);
|
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