Skip to content

Commit

Permalink
build (and update npm task runner to allow ignored tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrins committed Dec 23, 2022
1 parent 3eb52ff commit 84088ad
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 62 deletions.
2 changes: 1 addition & 1 deletion dist/tinycolor-min.js

Large diffs are not rendered by default.

62 changes: 37 additions & 25 deletions npm/cjs/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const tinycolor = require("./tinycolor.js");
const { Deno, testDefinitions } = require("@deno/shim-deno-test");
async function runDenoTests() {
for (const test of testDefinitions) {
if (test.ignore) {
console.log(`Ignoring ${test.name}`);
continue;
}
console.log(`Running ${test.name}`);
await test.fn();
console.log(`> Passed ${test.name}`);
Expand Down Expand Up @@ -2135,31 +2139,39 @@ Deno.test("tetrad", function () {
);
});

Deno.test("polyad", function () {
assertThrows(() => {
tinycolor("red").polyad();
});
assertThrows(() => {
tinycolor("red").polyad(-1);
});
assertThrows(() => {
tinycolor("red").polyad("invalid");
});
assertEquals(colorsToHexString(tinycolor("red").polyad(1)), "ff0000");
assertEquals(colorsToHexString(tinycolor("red").polyad("1")), "ff0000");
assertEquals(colorsToHexString(tinycolor("red").polyad(2)), "ff0000,00ffff");
assertEquals(
colorsToHexString(tinycolor("red").polyad(3)),
"ff0000,00ff00,0000ff"
);
assertEquals(
colorsToHexString(tinycolor("red").polyad(4)),
"ff0000,80ff00,00ffff,7f00ff"
);
assertEquals(
colorsToHexString(tinycolor("red").polyad(5)),
"ff0000,ccff00,00ff66,0066ff,cc00ff"
);
Deno.test({
name: "polyad",
// Disabled until https://github.com/bgrins/TinyColor/issues/254
ignore: true,
fn: function () {
assertThrows(() => {
tinycolor("red").polyad();
});
assertThrows(() => {
tinycolor("red").polyad(-1);
});
assertThrows(() => {
tinycolor("red").polyad("invalid");
});
assertEquals(colorsToHexString(tinycolor("red").polyad(1)), "ff0000");
assertEquals(colorsToHexString(tinycolor("red").polyad("1")), "ff0000");
assertEquals(
colorsToHexString(tinycolor("red").polyad(2)),
"ff0000,00ffff"
);
assertEquals(
colorsToHexString(tinycolor("red").polyad(3)),
"ff0000,00ff00,0000ff"
);
assertEquals(
colorsToHexString(tinycolor("red").polyad(4)),
"ff0000,80ff00,00ffff,7f00ff"
);
assertEquals(
colorsToHexString(tinycolor("red").polyad(5)),
"ff0000,ccff00,00ff66,0066ff,cc00ff"
);
},
});

runDenoTests();
Expand Down
4 changes: 4 additions & 0 deletions npm/cjs/test_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const tinycolor = require("./tinycolor.js");
const { Deno, testDefinitions } = require("@deno/shim-deno-test");
async function runDenoTests() {
for (const test of testDefinitions) {
if (test.ignore) {
console.log(`Ignoring ${test.name}`);
continue;
}
console.log(`Running ${test.name}`);
await test.fn();
console.log(`> Passed ${test.name}`);
Expand Down
7 changes: 4 additions & 3 deletions npm/cjs/tinycolor.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,10 @@
splitcomplement: function () {
return this._applyCombination(splitcomplement, arguments);
},
polyad: function (number) {
return this._applyCombination(polyad, [number]);
},
// Disabled until https://github.com/bgrins/TinyColor/issues/254
// polyad: function (number) {
// return this._applyCombination(polyad, [number]);
// },
triad: function () {
return this._applyCombination(polyad, [3]);
},
Expand Down
62 changes: 37 additions & 25 deletions npm/esm/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const { assertEquals, assert, assertThrows } = await import(
);
async function runDenoTests() {
for (const test of testDefinitions) {
if (test.ignore) {
console.log(`Ignoring ${test.name}`);
continue;
}
console.log(`Running ${test.name}`);
await test.fn();
console.log(`> Passed ${test.name}`);
Expand Down Expand Up @@ -2134,31 +2138,39 @@ Deno.test("tetrad", function () {
);
});

Deno.test("polyad", function () {
assertThrows(() => {
tinycolor("red").polyad();
});
assertThrows(() => {
tinycolor("red").polyad(-1);
});
assertThrows(() => {
tinycolor("red").polyad("invalid");
});
assertEquals(colorsToHexString(tinycolor("red").polyad(1)), "ff0000");
assertEquals(colorsToHexString(tinycolor("red").polyad("1")), "ff0000");
assertEquals(colorsToHexString(tinycolor("red").polyad(2)), "ff0000,00ffff");
assertEquals(
colorsToHexString(tinycolor("red").polyad(3)),
"ff0000,00ff00,0000ff"
);
assertEquals(
colorsToHexString(tinycolor("red").polyad(4)),
"ff0000,80ff00,00ffff,7f00ff"
);
assertEquals(
colorsToHexString(tinycolor("red").polyad(5)),
"ff0000,ccff00,00ff66,0066ff,cc00ff"
);
Deno.test({
name: "polyad",
// Disabled until https://github.com/bgrins/TinyColor/issues/254
ignore: true,
fn: function () {
assertThrows(() => {
tinycolor("red").polyad();
});
assertThrows(() => {
tinycolor("red").polyad(-1);
});
assertThrows(() => {
tinycolor("red").polyad("invalid");
});
assertEquals(colorsToHexString(tinycolor("red").polyad(1)), "ff0000");
assertEquals(colorsToHexString(tinycolor("red").polyad("1")), "ff0000");
assertEquals(
colorsToHexString(tinycolor("red").polyad(2)),
"ff0000,00ffff"
);
assertEquals(
colorsToHexString(tinycolor("red").polyad(3)),
"ff0000,00ff00,0000ff"
);
assertEquals(
colorsToHexString(tinycolor("red").polyad(4)),
"ff0000,80ff00,00ffff,7f00ff"
);
assertEquals(
colorsToHexString(tinycolor("red").polyad(5)),
"ff0000,ccff00,00ff66,0066ff,cc00ff"
);
},
});

runDenoTests();
4 changes: 4 additions & 0 deletions npm/esm/test_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const { assertEquals, assert, assertThrows } = await import(
);
async function runDenoTests() {
for (const test of testDefinitions) {
if (test.ignore) {
console.log(`Ignoring ${test.name}`);
continue;
}
console.log(`Running ${test.name}`);
await test.fn();
console.log(`> Passed ${test.name}`);
Expand Down
7 changes: 4 additions & 3 deletions npm/esm/tinycolor.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,10 @@ tinycolor.prototype = {
splitcomplement: function () {
return this._applyCombination(splitcomplement, arguments);
},
polyad: function (number) {
return this._applyCombination(polyad, [number]);
},
// Disabled until https://github.com/bgrins/TinyColor/issues/254
// polyad: function (number) {
// return this._applyCombination(polyad, [number]);
// },
triad: function () {
return this._applyCombination(polyad, [3]);
},
Expand Down
4 changes: 2 additions & 2 deletions npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions tinycolor.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,10 @@
splitcomplement: function () {
return this._applyCombination(splitcomplement, arguments);
},
polyad: function (number) {
return this._applyCombination(polyad, [number]);
},
// Disabled until https://github.com/bgrins/TinyColor/issues/254
// polyad: function (number) {
// return this._applyCombination(polyad, [number]);
// },
triad: function () {
return this._applyCombination(polyad, [3]);
},
Expand Down

0 comments on commit 84088ad

Please sign in to comment.