diff --git a/package.json b/package.json index 3357010ee..6f9403c08 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "scripts": { "lint": "eslint --ext .js,.ts,.tsx '**/*.{js,ts}'", - "test": "cross-env BABEL_ENV=test mocha --require @babel/register './packages/**/test/**/*.test.js' --require ts-node/register ./packages/**/test/*.test.ts", + "test": "cross-env BABEL_ENV=test mocha --require @babel/register './packages/**/test/**/*.test.js' ./packages/**/test/*.test.ts", "test:watch": "npm run test -- --reporter min --watch", "test:browser": "cross-env BABEL_ENV=test ENV=browser CHROME_BIN=\"$(which chrome || which chromium)\" karma start --single-run", "test:browser:watch": "npm run -s test:browser start -- --auto-watch", @@ -34,7 +34,9 @@ "@babel/cli": "^7.20.7", "@babel/core": "^7.20.12", "@babel/preset-env": "^7.20.2", + "@babel/preset-typescript": "^7.18.6", "@babel/register": "^7.18.9", + "@storybook/expect": "^27.5.2-0", "@typescript-eslint/eslint-plugin": "^5.50.0", "@typescript-eslint/parser": "^5.50.0", "all-contributors-cli": "^6.24.0", @@ -49,6 +51,7 @@ "eslint-config-xo": "^0.43.1", "eslint-plugin-import": "^2.27.5", "express": "^4.17.1", + "fast-deep-equal": "^3.1.3", "husky": "^3.0.5", "karma": "^4.3.0", "karma-browserify": "^6.1.0", @@ -62,8 +65,8 @@ "nyc": "^14.1.1", "patch-package": "^6.5.1", "prettier": "^2.8.3", - "should": "^13.2.3", - "source-map-support": "^0.5.21" + "source-map-support": "^0.5.21", + "typescript": "^4.9.5" }, "husky": { "hooks": { diff --git a/packages/core/package.json b/packages/core/package.json index 5c11ee051..ca86a656f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -39,9 +39,6 @@ "pixelmatch": "^4.0.2", "tinycolor2": "^1.4.1" }, - "devDependencies": { - "should": "^13.2.3" - }, "publishConfig": { "access": "public" } diff --git a/packages/core/test/utils/mime.test.js b/packages/core/test/utils/mime.test.js index 035fdf035..a973a37a4 100644 --- a/packages/core/test/utils/mime.test.js +++ b/packages/core/test/utils/mime.test.js @@ -1,4 +1,4 @@ -import should from "should/as-function"; +import expect from "@storybook/expect"; import { getType, getExtension, addType } from "../../src/utils/mime"; describe("Mime", () => { @@ -12,30 +12,30 @@ describe("Mime", () => { describe("getType", () => { it("should return undefined if not found", () => { - should(getType("/path/to.the/file.boop")).be.exactly(undefined); + expect(getType("/path/to.the/file.boop")).toBe(undefined); }); it("should return the correct mime", () => { - should(getType("/path/to.the/file.png")).be.exactly("image/png"); - should(getType("/path/to.the/file.gif")).be.exactly("image/gif"); - should(getType("/path/to.the/file.jpg")).be.exactly("image/jpeg"); - should(getType("/path/to.the/file.jpeg")).be.exactly("image/jpeg"); - should(getType("/path/to.the/file.bmp")).be.exactly("image/bmp"); - should(getType("/path/to.the/file.tiff")).be.exactly("image/tiff"); + expect(getType("/path/to.the/file.png")).toBe("image/png"); + expect(getType("/path/to.the/file.gif")).toBe("image/gif"); + expect(getType("/path/to.the/file.jpg")).toBe("image/jpeg"); + expect(getType("/path/to.the/file.jpeg")).toBe("image/jpeg"); + expect(getType("/path/to.the/file.bmp")).toBe("image/bmp"); + expect(getType("/path/to.the/file.tiff")).toBe("image/tiff"); }); }); describe("getExtension", () => { it("should return undefined if not found", () => { - should(getExtension("unknown/mime")).be.exactly(undefined); + expect(getExtension("unknown/mime")).toBe(undefined); }); it("should return the correct extension", () => { - should(getExtension("image/png")).be.exactly("png"); - should(getExtension("image/gif")).be.exactly("gif"); - should(getExtension("image/jpeg")).be.exactly("jpeg"); - should(getExtension("image/bmp")).be.exactly("bmp"); - should(getExtension("image/tiff")).be.exactly("tiff"); + expect(getExtension("image/png")).toBe("png"); + expect(getExtension("image/gif")).toBe("gif"); + expect(getExtension("image/jpeg")).toBe("jpeg"); + expect(getExtension("image/bmp")).toBe("bmp"); + expect(getExtension("image/tiff")).toBe("tiff"); }); }); }); diff --git a/packages/custom/types/tsconfig.json b/packages/custom/types/tsconfig.json index dcfe450fd..a2773dcea 100644 --- a/packages/custom/types/tsconfig.json +++ b/packages/custom/types/tsconfig.json @@ -6,6 +6,7 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, + "skipLibCheck": true, "noEmit": true, // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index". diff --git a/packages/jimp/test/async.test.js b/packages/jimp/test/async.test.js index dce254fb2..0295284e6 100644 --- a/packages/jimp/test/async.test.js +++ b/packages/jimp/test/async.test.js @@ -1,5 +1,5 @@ import fs from "fs"; -import should from "should"; +import expect from "@storybook/expect"; import { Jimp, getTestDir } from "@jimp/test-utils"; const imagesDir = getTestDir(__dirname) + "/images"; @@ -16,8 +16,8 @@ describe("Async functions", () => { const image = await Jimp.read(imagesDir + "/dice.png"); const writtenImage = await image.writeAsync(writePath); - should.exist(writtenImage); - fs.existsSync(writePath).should.be.true(); + expect(writtenImage).not.toBeUndefined(); + expect(fs.existsSync(writePath)).toBe(true); fs.unlinkSync(writePath); }); @@ -25,13 +25,13 @@ describe("Async functions", () => { const image = await Jimp.read(imagesDir + "/dice.png"); const buffer = await image.getBufferAsync(Jimp.AUTO); - should.exist(buffer); + expect(buffer.length).toBeGreaterThan(0); }); it("getBase64 returns promise", async () => { const image = await Jimp.read(imagesDir + "/dice.png"); const bas64 = await image.getBase64Async(Jimp.AUTO); - should.exist(bas64); + expect(bas64.length).toBeGreaterThan(0); }); }); diff --git a/packages/jimp/test/callbacks.test.js b/packages/jimp/test/callbacks.test.js index 07dfba942..f84333a13 100644 --- a/packages/jimp/test/callbacks.test.js +++ b/packages/jimp/test/callbacks.test.js @@ -1,7 +1,9 @@ import { Jimp, mkJGD, hasOwnProp } from "@jimp/test-utils"; +import expect from "@storybook/expect"; import configure from "@jimp/custom"; import plugins from "@jimp/plugins"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [plugins] }, Jimp); @@ -213,7 +215,7 @@ describe("Callbacks", () => { function save(err, image) { if (err) return done(err); - image.getJGDSync().should.be.sameJGD(result); + expectToBeJGD(image.getJGDSync(), result); done(); } diff --git a/packages/jimp/test/colordiff.test.js b/packages/jimp/test/colordiff.test.js index 6255dd6c9..e8b7059c1 100644 --- a/packages/jimp/test/colordiff.test.js +++ b/packages/jimp/test/colordiff.test.js @@ -1,57 +1,60 @@ import { Jimp } from "@jimp/test-utils"; +import expect from "@storybook/expect"; // Convert [0..1] float to a percent value with only one decimal. const pct = (n) => ((n * 1000) << 0) / 10; describe("compute color difference", () => { it("totally opaque (no alpha defined)", () => { - Jimp.colorDiff( - { r: 255, g: 0, b: 0 }, - { r: 255, g: 0, b: 0 } - ).should.be.equal(0, "both red"); - - pct( - Jimp.colorDiff({ r: 255, g: 0, b: 0 }, { r: 0, g: 0, b: 0 }) - ).should.be.equal(33.3, "red x black"); - - pct( - Jimp.colorDiff({ r: 255, g: 0, b: 0 }, { r: 0, g: 255, b: 0 }) - ).should.be.equal(66.6, "red x green"); - - Jimp.colorDiff( - { r: 255, g: 0, b: 0 }, - { r: 0, g: 255, b: 255 } - ).should.be.equal(1, "red x cyan"); - - Jimp.colorDiff( - { r: 0, g: 0, b: 0 }, - { r: 255, g: 255, b: 255 } - ).should.be.equal(1, "black x white"); + expect( + Jimp.colorDiff({ r: 255, g: 0, b: 0 }, { r: 255, g: 0, b: 0 }) + ).toEqual(0); + + expect( + pct(Jimp.colorDiff({ r: 255, g: 0, b: 0 }, { r: 0, g: 0, b: 0 })) + ).toEqual(33.3); + + expect( + pct(Jimp.colorDiff({ r: 255, g: 0, b: 0 }, { r: 0, g: 255, b: 0 })) + ).toEqual(66.6); + + expect( + Jimp.colorDiff({ r: 255, g: 0, b: 0 }, { r: 0, g: 255, b: 255 }) + ).toEqual(1); + + expect( + Jimp.colorDiff({ r: 0, g: 0, b: 0 }, { r: 255, g: 255, b: 255 }) + ).toEqual(1); }); it("totally transparent", () => { - Jimp.colorDiff( - { r: 255, g: 0, b: 0, a: 0 }, - { r: 255, g: 0, b: 0, a: 0 } - ).should.be.equal(0, "both transparent red"); - - Jimp.colorDiff( - { r: 0, g: 0, b: 0, a: 0 }, - { r: 255, g: 255, b: 255, a: 0 } - ).should.be.equal(1, "transparent black x transparent white"); + expect( + Jimp.colorDiff({ r: 255, g: 0, b: 0, a: 0 }, { r: 255, g: 0, b: 0, a: 0 }) + ).toEqual(0); + + expect( + Jimp.colorDiff( + { r: 0, g: 0, b: 0, a: 0 }, + { r: 255, g: 255, b: 255, a: 0 } + ) + ).toEqual(1); }); it("different alpha", () => { - pct( - Jimp.colorDiff( - { r: 255, g: 0, b: 0, a: 100 }, - { r: 255, g: 0, b: 0, a: 150 } + expect( + pct( + Jimp.colorDiff( + { r: 255, g: 0, b: 0, a: 100 }, + { r: 255, g: 0, b: 0, a: 150 } + ) ) - ).should.be.equal(3.8, "both red"); + ).toEqual(3.8); - Jimp.colorDiff( - { r: 0, g: 0, b: 0, a: 0 }, - { r: 255, g: 255, b: 255, a: 255 } - ).should.be.equal(1, "transparent black x transparent white"); + expect( + Jimp.colorDiff( + { r: 0, g: 0, b: 0, a: 0 }, + { r: 255, g: 255, b: 255, a: 255 } + ) + ).toEqual(1); }); }); diff --git a/packages/jimp/test/composite.test.js b/packages/jimp/test/composite.test.js index b860961db..ef4332655 100644 --- a/packages/jimp/test/composite.test.js +++ b/packages/jimp/test/composite.test.js @@ -1,5 +1,5 @@ import fs from "fs"; -import should from "should"; +import expect from "@storybook/expect"; import { Jimp, getTestDir } from "@jimp/test-utils"; @@ -35,7 +35,7 @@ describe("composite", () => { fs.unlinkSync(testPath); - should.deepEqual(one, two); + expect(one).toEqual(two); }); it("should handle edges correctly", async () => { @@ -64,6 +64,6 @@ describe("composite", () => { fs.unlinkSync(testPath); - should.deepEqual(one, two); + expect(one).toEqual(two); }); }); diff --git a/packages/jimp/test/diff.test.js b/packages/jimp/test/diff.test.js index 20938ebba..519ae29a3 100644 --- a/packages/jimp/test/diff.test.js +++ b/packages/jimp/test/diff.test.js @@ -1,4 +1,5 @@ import { Jimp, mkJGD } from "@jimp/test-utils"; +import expect from "@storybook/expect"; describe("Compare image difference", () => { let imgs = [ @@ -19,8 +20,9 @@ describe("Compare image difference", () => { it("images 0 and 1", () => { const diff = Jimp.diff(imgs[0], imgs[1]); - diff.percent.should.be.equal(0.75); - diff.image.getJGDSync().should.be.sameJGD({ + + expect(diff.percent).toBe(0.75); + expect(diff.image.getJGDSync()).toEqual({ width: 4, height: 4, data: [ @@ -33,8 +35,9 @@ describe("Compare image difference", () => { it("images 0 and 2", () => { const diff = Jimp.diff(imgs[0], imgs[2]); - diff.percent.should.be.equal(0); - diff.image.getJGDSync().should.be.sameJGD({ + + expect(diff.percent).toBe(0); + expect(diff.image.getJGDSync()).toEqual({ width: 4, height: 4, data: [ @@ -47,8 +50,8 @@ describe("Compare image difference", () => { it("images 0 and 3", () => { const diff = Jimp.diff(imgs[0], imgs[3]); - diff.percent.should.be.equal(0); - diff.image.getJGDSync().should.be.sameJGD({ + expect(diff.percent).toBe(0); + expect(diff.image.getJGDSync()).toEqual({ width: 4, height: 4, data: [ @@ -60,12 +63,12 @@ describe("Compare image difference", () => { }); it("allows to set a different threshold", () => { - Jimp.diff(imgs[0], imgs[3], 0.1).percent.should.be.equal(0); - Jimp.diff(imgs[0], imgs[3], 0).percent.should.be.equal(0.25); + expect(Jimp.diff(imgs[0], imgs[3], 0.1).percent).toBe(0); + expect(Jimp.diff(imgs[0], imgs[3], 0).percent).toBe(0.25); }); it("throws an error if threshold is invalid", () => { - (() => Jimp.diff(imgs[0], imgs[3], "invalid")).should.throw( + expect(() => Jimp.diff(imgs[0], imgs[3], -1)).toThrow( "threshold must be a number between 0 and 1" ); }); diff --git a/packages/jimp/test/events.test.js b/packages/jimp/test/events.test.js index e07c6b647..2519fa85e 100644 --- a/packages/jimp/test/events.test.js +++ b/packages/jimp/test/events.test.js @@ -1,6 +1,8 @@ import { Jimp as jimp, mkJGD, getTestDir } from "@jimp/test-utils"; import configure from "@jimp/custom"; import plugins from "@jimp/plugins"; +import expect from "@storybook/expect"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const Jimp = configure({ plugins: [plugins] }, jimp); @@ -9,8 +11,8 @@ describe("Events", () => { it("initializes", (done) => { new Jimp(mkJGD("▴▵")) .on("initialized", function (data) { - this.getJGDSync().should.be.sameJGD(mkJGD("▴▵")); - data.methodName.should.be.equal("constructor"); + expectToBeJGD(this.getJGDSync(), mkJGD("▴▵")); + expect(data.methodName).toBe("constructor"); done(); }) .on("error", done); @@ -19,7 +21,7 @@ describe("Events", () => { it("initializes with a file", (done) => { new Jimp(getTestDir(__dirname) + "/images/lenna.png") .on("initialized", function () { - this.bitmap.width.should.be.equal(512); + expect(this.bitmap.width).toBe(512); done(); }) .on("error", done); @@ -28,56 +30,56 @@ describe("Events", () => { // (8bit Hex, Hex, RGB, RGBA, HSL, HSLA, HSV, HSVA, Named) it("initializes with a 8bit hex color", async () => { const image = await Jimp.create(2, 2, 0xffffffff); - image.getPixelColor(1, 1).should.be.equal(0xffffffff); + expect(image.getPixelColor(1, 1)).toBe(0xffffffff); }); it("initializes with a css color (Hex)", async () => { const image = await Jimp.create(2, 2, "#FFFFFF"); - image.getPixelColor(1, 1).should.be.equal(0xffffffff); + expect(image.getPixelColor(1, 1)).toBe(0xffffffff); }); it("initializes with a css color (RGB)", async () => { const image = await Jimp.create(2, 2, "rgb (255, 255, 255)"); - image.getPixelColor(1, 1).should.be.equal(0xffffffff); + expect(image.getPixelColor(1, 1)).toBe(0xffffffff); }); it("initializes with a css color (RGBA)", async () => { const image = await Jimp.create(2, 2, "rgba (255, 255, 255, 1)"); - image.getPixelColor(1, 1).should.be.equal(0xffffffff); + expect(image.getPixelColor(1, 1)).toBe(0xffffffff); }); it("initializes with a css color (HSL)", async () => { const image = await Jimp.create(2, 2, "hsl (100%, 100%, 100%)"); - image.getPixelColor(1, 1).should.be.equal(0xffffffff); + expect(image.getPixelColor(1, 1)).toBe(0xffffffff); }); it("initializes with a css color (HSLA)", async () => { const image = await Jimp.create(2, 2, "hsla (100%, 100%, 100%, 1)"); - image.getPixelColor(1, 1).should.be.equal(0xffffffff); + expect(image.getPixelColor(1, 1)).toBe(0xffffffff); }); it("initializes with a css color (HSV)", async () => { const image = await Jimp.create(2, 2, "hsv (0%, 0%, 100%)"); - image.getPixelColor(1, 1).should.be.equal(0xffffffff); + expect(image.getPixelColor(1, 1)).toBe(0xffffffff); }); it("initializes with a css color (HSVA)", async () => { const image = await Jimp.create(2, 2, "hsva (0%, 0%, 100%, 1)"); - image.getPixelColor(1, 1).should.be.equal(0xffffffff); + expect(image.getPixelColor(1, 1)).toBe(0xffffffff); }); it("initializes with a css color (Named)", async () => { const image = await Jimp.create(2, 2, "WHITE"); - image.getPixelColor(1, 1).should.be.equal(0xffffffff); + expect(image.getPixelColor(1, 1)).toBe(0xffffffff); }); }); describe("on change", () => { it("call before-change without callback", (done) => { const img = new Jimp(8, 8).on("before-change", function (data) { - this.should.be.instanceof(Jimp); - data.methodName.should.be.equal("crop"); - this.bitmap.width.should.be.equal(8, "not changed yet"); + expect(this).toBeInstanceOf(Jimp); + expect(data.methodName).toBe("crop"); + expect(this.bitmap.width).toBe(8); done(); }); img.crop(0, 0, 4, 4); @@ -85,9 +87,9 @@ describe("Events", () => { it("call changed without callback", (done) => { const img = new Jimp(8, 8).on("changed", function (data) { - this.should.be.instanceof(Jimp); - data.methodName.should.be.equal("crop"); - this.bitmap.width.should.be.equal(4, "just changed!"); + expect(this).toBeInstanceOf(Jimp); + expect(data.methodName).toBe("crop"); + expect(this.bitmap.width).toBe(4); done(); }); img.crop(0, 0, 4, 4); @@ -96,13 +98,13 @@ describe("Events", () => { it("call before-change with callback", (done) => { let eventEmited = false; const img = new Jimp(8, 8).on("before-change", function (data) { - this.should.be.instanceof(Jimp); - data.methodName.should.be.equal("crop"); - this.bitmap.width.should.be.equal(8, "not changed yet"); + expect(this).toBeInstanceOf(Jimp); + expect(data.methodName).toBe("crop"); + expect(this.bitmap.width).toBe(8); eventEmited = true; }); img.crop(0, 0, 4, 4, () => { - eventEmited.should.be.ok(); + expect(eventEmited).toBe(true); done(); }); }); @@ -110,13 +112,13 @@ describe("Events", () => { it("call changed with callback", (done) => { let eventEmited = false; const img = new Jimp(8, 8).on("changed", function (data) { - this.should.be.instanceof(Jimp); - data.methodName.should.be.equal("crop"); - this.bitmap.width.should.be.equal(4, "just changed!"); + expect(this).toBeInstanceOf(Jimp); + expect(data.methodName).toBe("crop"); + expect(this.bitmap.width).toBe(4); eventEmited = true; }); img.crop(0, 0, 4, 4, () => { - eventEmited.should.be.ok(); + expect(eventEmited).toBe(true); done(); }); }); @@ -130,7 +132,7 @@ describe("Events", () => { .on("changed", function () { widthSequence.push("out:" + this.bitmap.width); if (widthSequence.length === 6) { - widthSequence.should.be.deepEqual([ + expect(widthSequence).toEqual([ "in:8", "out:6", "in:6", @@ -153,7 +155,7 @@ describe("Events", () => { .on("changed", function () { widthSequence.push("out:" + this.bitmap.width); if (widthSequence.length === 6) { - widthSequence.should.be.deepEqual([ + expect(widthSequence).toEqual([ "in:8", "out:6", "in:6", @@ -176,8 +178,8 @@ describe("Events", () => { throw new Error("must not init!"); }) .on("error", (err) => { - err.should.be.instanceof(Error); - err.methodName.should.be.equal("constructor"); + expect(err).toBeInstanceOf(Error); + expect(err.methodName).toBe("constructor"); done(); }); }); @@ -194,8 +196,8 @@ describe("Events", () => { .on("error", (err) => { setTimeout(() => { // Give some time to ensure `changed` will not emit. - err.methodName.should.be.equal("crop"); - evBeforeChangeEmited.should.be.ok(); + expect(err.methodName).toBe("crop"); + expect(evBeforeChangeEmited).toBe(true); done(); }, 300); }); @@ -213,17 +215,17 @@ describe("Events", () => { eventsEmited.push(data.eventName); }); img.on("before-clone", function (data) { - this.should.be.instanceof(Jimp); - data.methodName.should.be.equal("clone"); + expect(this).toBeInstanceOf(Jimp); + expect(data.methodName).toBe("clone"); evBeforeCloneEmited = true; }); img.on("cloned", function (data) { - evBeforeCloneEmited.should.be.ok(); - eventsEmited.should.be.deepEqual(["before-clone", "cloned"]); - this.should.be.equal(img, "this is NOT the clone! Is the emitter."); - data.methodName.should.be.equal("clone"); - data.clone.should.be.instanceof(Jimp); - data.clone.getJGDSync().should.be.sameJGD(mkJGD("▴▵")); + expect(evBeforeCloneEmited).toBe(true); + expect(eventsEmited).toEqual(["before-clone", "cloned"]); + expect(this).toEqual(img); + expect(data.methodName).toBe("clone"); + expect(data.clone).toBeInstanceOf(Jimp); + expectToBeJGD(data.clone.getJGDSync(), mkJGD("▴▵")); done(); }); img.clone(); @@ -242,24 +244,22 @@ describe("Events", () => { eventsEmited.push(data.eventName); }) .on("before-clone", function (data) { - this.should.be.instanceof(Jimp); - data.methodName.should.be.equal("clone"); + expect(this).toBeInstanceOf(Jimp); + + expect(data.methodName).toBe("clone"); evBeforeCloneEmited = true; }) .on("cloned", function (data) { - this.should.be.equal( - img, - "this is NOT the clone! Is the emitter." - ); - data.methodName.should.be.equal("clone"); - data.clone.should.be.instanceof(Jimp); - data.clone.getJGDSync().should.be.sameJGD(mkJGD("▴▵")); + expect(this).toEqual(img); + expect(data.methodName).toBe("clone"); + expect(data.clone).toBeInstanceOf(Jimp); + expectToBeJGD(data.clone.getJGDSync(), mkJGD("▴▵")); evClonedEmited = true; }); img.clone(() => { - evBeforeCloneEmited.should.be.ok(); - evClonedEmited.should.be.ok(); - eventsEmited.should.be.deepEqual(["before-clone", "cloned"]); + expect(evBeforeCloneEmited).toBe(true); + expect(evClonedEmited).toBe(true); + expect(eventsEmited).toEqual(["before-clone", "cloned"]); done(); }); }) diff --git a/packages/jimp/test/exif-rotation.test.js b/packages/jimp/test/exif-rotation.test.js index 1aba3789c..16608edcf 100644 --- a/packages/jimp/test/exif-rotation.test.js +++ b/packages/jimp/test/exif-rotation.test.js @@ -1,4 +1,5 @@ import { Jimp, getTestDir } from "@jimp/test-utils"; +import expect from "@storybook/expect"; import configure from "@jimp/custom"; @@ -10,9 +11,9 @@ describe("EXIF orientation", () => { const regularImg = await imageWithOrientation(1); const orientedImg = await imageWithOrientation(orientation); - orientedImg.getWidth().should.be.equal(regularImg.getWidth()); - orientedImg.getHeight().should.be.equal(regularImg.getHeight()); - Jimp.distance(regularImg, orientedImg).should.lessThan(0.07); + expect(orientedImg.getWidth()).toBe(regularImg.getWidth()); + expect(orientedImg.getHeight()).toBe(regularImg.getHeight()); + expect(Jimp.distance(regularImg, orientedImg)).toBeLessThan(0.07); }); } }); diff --git a/packages/jimp/test/filetypes.test.js b/packages/jimp/test/filetypes.test.js index b00f5083b..7ee497906 100644 --- a/packages/jimp/test/filetypes.test.js +++ b/packages/jimp/test/filetypes.test.js @@ -1,6 +1,6 @@ import fs from "fs"; -import should from "should"; import { Jimp, getTestDir } from "@jimp/test-utils"; +import expect from "@storybook/expect"; const imagesDir = getTestDir(__dirname) + "/images"; @@ -14,8 +14,8 @@ describe("FileType", () => { const image = await Jimp.read(imagesDir + "/dice.png"); const writtenImage = await image.writeAsync(writePath); - should.exist(writtenImage); - fs.existsSync(writePath).should.be.true(); + expect(writtenImage).not.toBeUndefined(); + expect(fs.existsSync(writePath)).toBe(true); fs.unlinkSync(writePath); }); @@ -27,21 +27,21 @@ describe("FileType", () => { height: image.getHeight(), }); - should.exist(imageFromBitmap); + expect(imageFromBitmap).not.toBeUndefined(); }); it("clones with the correct MIME type", async () => { const image = await Jimp.read(imagesDir + "/cops.jpg"); const clone = image.clone(); - image.getMIME().should.be.equal(clone.getMIME()); + expect(image.getMIME()).toBe(clone.getMIME()); }); it("clones gif with the correct MIME type", async () => { const image = await Jimp.read(imagesDir + "/flower.gif"); const clone = image.clone(); - image.getMIME().should.be.equal(clone.getMIME()); + expect(image.getMIME()).toBe(clone.getMIME()); }); }); @@ -49,12 +49,12 @@ describe("hasAlpha", () => { it("image with no alpha", async () => { const image = await Jimp.read(imagesDir + "/cops.jpg"); - image.hasAlpha().should.be.equal(false); + expect(image.hasAlpha()).toBe(false); }); it("image with alpha", async () => { const image = await Jimp.read(imagesDir + "/dice.png"); - image.hasAlpha().should.be.equal(true); + expect(image.hasAlpha()).toBe(true); }); }); diff --git a/packages/jimp/test/hash.test.js b/packages/jimp/test/hash.test.js index 0f01e0c4e..0e7597e1c 100644 --- a/packages/jimp/test/hash.test.js +++ b/packages/jimp/test/hash.test.js @@ -2,6 +2,7 @@ import { Jimp, getTestDir } from "@jimp/test-utils"; import configure from "@jimp/custom"; import types from "@jimp/types"; import plugins from "@jimp/plugins"; +import expect from "@storybook/expect"; const jimp = configure({ types: [types], plugins: [plugins] }, Jimp); @@ -11,29 +12,27 @@ describe("hash", () => { it("base 2", async () => { const image = await jimp.read(imagesDir + "/dice.png"); - image - .hash(2) - .should.be.equal( - "1100010000011111011010111110000000010101001011010101101000010010" - ); + expect(image.hash(2)).toBe( + "1100010000011111011010111110000000010101001011010101101000010010" + ); }); it("base 10 (decimal)", async () => { const image = await jimp.read(imagesDir + "/cops.jpg"); - image.hash(10).should.be.equal("13442314021806033441"); + expect(image.hash(10)).toBe("13442314021806033441"); }); it("base 16 (hex)", async () => { const image = await jimp.read(imagesDir + "/rgb.tiff"); - image.hash(16).should.be.equal("949800481007044c"); + expect(image.hash(16)).toBe("949800481007044c"); }); it("base 64", async () => { const image = await jimp.read(imagesDir + "/windows95.bmp"); - image.hash(64).should.be.equal("fb0xj0Mw400"); + expect(image.hash(64)).toBe("fb0xj0Mw400"); }); it("base 23", async function () { @@ -42,13 +41,13 @@ describe("hash", () => { this.timeout(10000); const image = await jimp.read(imagesDir + "/panoramic.jpg"); - image.hash(23).should.be.exactly("0m1m2id7l7cl4fb"); + expect(image.hash(23)).toBe("0m1m2id7l7cl4fb"); }); it("base 17", async () => { const image = await jimp.read(imagesDir + "/lenna.png"); - image.hash(17).should.be.equal("4fa6aga5a64ad0c1"); + expect(image.hash(17)).toBe("4fa6aga5a64ad0c1"); }); }); @@ -59,9 +58,7 @@ describe("pHash", () => { const image2 = await Jimp.read(imagesDir + "/mask.png"); const hash = image1.pHash(); - image2 - .distanceFromHash(hash) - .should.be.equal(Jimp.distance(image1, image2)); + expect(image2.distanceFromHash(hash)).toBe(Jimp.distance(image1, image2)); }); it("should calculate the distance using compareHashes.", async function () { @@ -72,7 +69,7 @@ describe("pHash", () => { const hash1 = image1.pHash(); const hash2 = image2.pHash(); - Jimp.compareHashes(hash1, hash2).should.be.equal( + expect(Jimp.compareHashes(hash1, hash2)).toBe( Jimp.distance(image1, image2) ); }); diff --git a/packages/jimp/test/scan.test.js b/packages/jimp/test/scan.test.js index ce5ab9d97..2d5413c2a 100644 --- a/packages/jimp/test/scan.test.js +++ b/packages/jimp/test/scan.test.js @@ -1,4 +1,5 @@ import { Jimp, mkJGD } from "@jimp/test-utils"; +import { expectToBeJGD } from "@jimp/test-utils/src"; describe("Scan (pixel matrix modification)", () => { const barsJGD = mkJGD("▴▴▸▸▾▾◆◆", "▴▴▸▸▾▾◆◆", "▵▵▹▹▿▿◇◇"); @@ -6,7 +7,7 @@ describe("Scan (pixel matrix modification)", () => { it("draw bars with scan", async () => { const image = await Jimp.create(8, 3); - image + const modifiedImage = image .scan( 0, 0, @@ -26,8 +27,9 @@ describe("Scan (pixel matrix modification)", () => { this.bitmap.data[idx + 3] = y === 2 ? 0x7f : 0xff; } ) - .getJGDSync() - .should.be.sameJGD(barsJGD, "Color bars"); + .getJGDSync(); + + expectToBeJGD(modifiedImage, barsJGD); }); it("draw bars with iterate scan", async () => { @@ -52,7 +54,7 @@ describe("Scan (pixel matrix modification)", () => { image.bitmap.data[idx + 3] = y === 2 ? 0x7f : 0xff; } - j.getJGDSync().should.be.sameJGD(barsJGD, "Color bars"); + expectToBeJGD(j.getJGDSync(), barsJGD); }); it("draw bars with (get|set)PixelColor", async () => { @@ -67,22 +69,15 @@ describe("Scan (pixel matrix modification)", () => { } } - image - .getJGDSync() - .should.be.sameJGD( - mkJGD("▾▾▴▴▸▸▰▰", "▾▾▴▴▸▸▰▰", "▿▿▵▵▹▹▱▱"), - "Replaced color bars" - ); + expectToBeJGD( + image.getJGDSync(), + mkJGD("▾▾▴▴▸▸▰▰", "▾▾▴▴▸▸▰▰", "▿▿▵▵▹▹▱▱") + ); }); it("create a image with plain color", async () => { const image = await Jimp.create(6, 3, 0xff0000ff); - image - .getJGDSync() - .should.be.sameJGD( - mkJGD("▴▴▴▴▴▴", "▴▴▴▴▴▴", "▴▴▴▴▴▴"), - "A pure red image" - ); + expectToBeJGD(image.getJGDSync(), mkJGD("▴▴▴▴▴▴", "▴▴▴▴▴▴", "▴▴▴▴▴▴")); }); }); diff --git a/packages/jimp/types/tsconfig.json b/packages/jimp/types/tsconfig.json index 6dbbf36d9..eb1dd15b0 100644 --- a/packages/jimp/types/tsconfig.json +++ b/packages/jimp/types/tsconfig.json @@ -6,6 +6,7 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, + "skipLibCheck": true, "noEmit": true, // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index". diff --git a/packages/plugin-blit/test/blit.test.js b/packages/plugin-blit/test/blit.test.js index d4e11a1a8..a9b71cb0c 100644 --- a/packages/plugin-blit/test/blit.test.js +++ b/packages/plugin-blit/test/blit.test.js @@ -1,8 +1,10 @@ import { Jimp, mkJGD, getTestDir } from "@jimp/test-utils"; import jpeg from "@jimp/jpeg"; import configure from "@jimp/custom"; +import expect from "@storybook/expect"; import blit from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ types: [jpeg], plugins: [blit] }, Jimp); const testDir = getTestDir(__dirname); @@ -44,117 +46,99 @@ describe("Blit over image", function () { }); it("blit on top, with no crop", () => { - targetImg - .clone() - .blit(srcImg, 0, 0) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "□□□□□□▸▸", - "□▥▥▥▥□▸▸", - "□▥■■▥□▸▸", - "□▥■■▥□▸▸", - "□▥▥▥▥□◆◆", - "□□□□□□◆◆", - "▾▾▾▾◆◆◆◆", - "▾▾▾▾◆◆◆◆" - ) - ); + expectToBeJGD( + targetImg.clone().blit(srcImg, 0, 0).getJGDSync(), + mkJGD( + "□□□□□□▸▸", + "□▥▥▥▥□▸▸", + "□▥■■▥□▸▸", + "□▥■■▥□▸▸", + "□▥▥▥▥□◆◆", + "□□□□□□◆◆", + "▾▾▾▾◆◆◆◆", + "▾▾▾▾◆◆◆◆" + ) + ); }); it("blit on middle, with no crop", () => { - targetImg - .clone() - .blit(srcImg, 1, 1) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "▴▴▴▴▸▸▸▸", - "▴□□□□□□▸", - "▴□▥▥▥▥□▸", - "▴□▥■■▥□▸", - "▾□▥■■▥□◆", - "▾□▥▥▥▥□◆", - "▾□□□□□□◆", - "▾▾▾▾◆◆◆◆" - ) - ); + expectToBeJGD( + targetImg.clone().blit(srcImg, 1, 1).getJGDSync(), + mkJGD( + "▴▴▴▴▸▸▸▸", + "▴□□□□□□▸", + "▴□▥▥▥▥□▸", + "▴□▥■■▥□▸", + "▾□▥■■▥□◆", + "▾□▥▥▥▥□◆", + "▾□□□□□□◆", + "▾▾▾▾◆◆◆◆" + ) + ); }); it("blit on middle, with x,y crop", () => { - targetImg - .clone() - .blit(srcImg, 2, 2, 1, 1, 5, 5) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "▴▴▴▴▸▸▸▸", - "▴▴▴▴▸▸▸▸", - "▴▴▥▥▥▥□▸", - "▴▴▥■■▥□▸", - "▾▾▥■■▥□◆", - "▾▾▥▥▥▥□◆", - "▾▾□□□□□◆", - "▾▾▾▾◆◆◆◆" - ) - ); + expectToBeJGD( + targetImg.clone().blit(srcImg, 2, 2, 1, 1, 5, 5).getJGDSync(), + mkJGD( + "▴▴▴▴▸▸▸▸", + "▴▴▴▴▸▸▸▸", + "▴▴▥▥▥▥□▸", + "▴▴▥■■▥□▸", + "▾▾▥■■▥□◆", + "▾▾▥▥▥▥□◆", + "▾▾□□□□□◆", + "▾▾▾▾◆◆◆◆" + ) + ); }); it("blit on middle, with x,y,w,h crop", () => { - targetImg - .clone() - .blit(srcImg, 2, 2, 1, 1, 4, 4) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "▴▴▴▴▸▸▸▸", - "▴▴▴▴▸▸▸▸", - "▴▴▥▥▥▥▸▸", - "▴▴▥■■▥▸▸", - "▾▾▥■■▥◆◆", - "▾▾▥▥▥▥◆◆", - "▾▾▾▾◆◆◆◆", - "▾▾▾▾◆◆◆◆" - ) - ); + expectToBeJGD( + targetImg.clone().blit(srcImg, 2, 2, 1, 1, 4, 4).getJGDSync(), + mkJGD( + "▴▴▴▴▸▸▸▸", + "▴▴▴▴▸▸▸▸", + "▴▴▥▥▥▥▸▸", + "▴▴▥■■▥▸▸", + "▾▾▥■■▥◆◆", + "▾▾▥▥▥▥◆◆", + "▾▾▾▾◆◆◆◆", + "▾▾▾▾◆◆◆◆" + ) + ); }); it("blit partially out, on top-left", () => { - targetImg - .clone() - .blit(srcImg, -1, -1) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "▥▥▥▥□▸▸▸", - "▥■■▥□▸▸▸", - "▥■■▥□▸▸▸", - "▥▥▥▥□▸▸▸", - "□□□□□◆◆◆", - "▾▾▾▾◆◆◆◆", - "▾▾▾▾◆◆◆◆", - "▾▾▾▾◆◆◆◆" - ) - ); + expectToBeJGD( + targetImg.clone().blit(srcImg, -1, -1).getJGDSync(), + mkJGD( + "▥▥▥▥□▸▸▸", + "▥■■▥□▸▸▸", + "▥■■▥□▸▸▸", + "▥▥▥▥□▸▸▸", + "□□□□□◆◆◆", + "▾▾▾▾◆◆◆◆", + "▾▾▾▾◆◆◆◆", + "▾▾▾▾◆◆◆◆" + ) + ); }); it("blit partially out, on bottom-right", () => { - targetImg - .clone() - .blit(srcImg, 3, 3) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "▴▴▴▴▸▸▸▸", - "▴▴▴▴▸▸▸▸", - "▴▴▴▴▸▸▸▸", - "▴▴▴□□□□□", - "▾▾▾□▥▥▥▥", - "▾▾▾□▥■■▥", - "▾▾▾□▥■■▥", - "▾▾▾□▥▥▥▥" - ) - ); + expectToBeJGD( + targetImg.clone().blit(srcImg, 3, 3).getJGDSync(), + mkJGD( + "▴▴▴▴▸▸▸▸", + "▴▴▴▴▸▸▸▸", + "▴▴▴▴▸▸▸▸", + "▴▴▴□□□□□", + "▾▾▾□▥▥▥▥", + "▾▾▾□▥■■▥", + "▾▾▾□▥■■▥", + "▾▾▾□▥▥▥▥" + ) + ); }); it("blit alpha", async () => { @@ -162,9 +146,7 @@ describe("Blit over image", function () { const dice = await Jimp.read(testDir + "/images/dice.png"); const image = await Jimp.read(testDir + "/images/cops.jpg"); - image - .blit(dice, 0, 0) - .bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + expect(image.blit(dice, 0, 0).bitmap.data).toEqual(expectedImg.bitmap.data); }); async function createCat(catNum, len) { @@ -218,18 +200,19 @@ describe("Blit over image", function () { testDir + "/images/cat-results/small-cat.png" ); const small = await createCat(0.3, 1); - small.bitmap.data.should.be.deepEqual(expectedSmall.bitmap.data); + + expect(small.bitmap.data).toEqual(expectedSmall.bitmap.data); const expectedMedium = await Jimp.read( testDir + "/images/cat-results/medium-cat.png" ); const medium = await createCat(0.6, 7); - medium.bitmap.data.should.be.deepEqual(expectedMedium.bitmap.data); + expect(medium.bitmap.data).toEqual(expectedMedium.bitmap.data); const expectedLarge = await Jimp.read( testDir + "/images/cat-results/large-cat.png" ); const large = await createCat(0.9, 20); - large.bitmap.data.should.be.deepEqual(expectedLarge.bitmap.data); + expect(large.bitmap.data).toEqual(expectedLarge.bitmap.data); }); }); diff --git a/packages/plugin-circle/test/circle.test.js b/packages/plugin-circle/test/circle.test.js index 19fc95d04..afeb6c6b7 100644 --- a/packages/plugin-circle/test/circle.test.js +++ b/packages/plugin-circle/test/circle.test.js @@ -1,5 +1,6 @@ import { Jimp, mkJGD, getTestDir } from "@jimp/test-utils"; import configure from "@jimp/custom"; +import expect from "@storybook/expect"; import circle from "../src"; @@ -25,7 +26,7 @@ describe("Circle", () => { ) ); - imgSrc.circle().bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + expect(imgSrc.circle().bitmap.data).toEqual(expectedImg.bitmap.data); }); it("makes a circle using provided radius", async () => { @@ -47,9 +48,9 @@ describe("Circle", () => { ) ); - imgSrc - .circle({ radius: 3 }) - .bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + expect(imgSrc.circle({ radius: 3 }).bitmap.data).toEqual( + expectedImg.bitmap.data + ); }); it("should ", async () => { @@ -71,8 +72,8 @@ describe("Circle", () => { ) ); - imgSrc - .circle({ radius: 5, x: 5, y: 5 }) - .bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + expect(imgSrc.circle({ radius: 5, x: 5, y: 5 }).bitmap.data).toEqual( + expectedImg.bitmap.data + ); }); }); diff --git a/packages/plugin-color/test/color.test.js b/packages/plugin-color/test/color.test.js index 562808bf5..f7d91e521 100644 --- a/packages/plugin-color/test/color.test.js +++ b/packages/plugin-color/test/color.test.js @@ -2,6 +2,7 @@ import { Jimp, donutJGD } from "@jimp/test-utils"; import configure from "@jimp/custom"; import color from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [color] }, Jimp); @@ -17,33 +18,33 @@ describe("canvas color transformation", () => { ]) .getJGDSync(); - newJGD.should.be.sameJGD(donutJGD(0x40404000, 0x80ffff88, 0x80ffffff)); + expectToBeJGD(newJGD, donutJGD(0x40404000, 0x80ffff88, 0x80ffffff)); }); it("lighten", async () => { const image = await jimp.read(redDonutJGD); - image - .color([{ apply: "lighten", params: [25] }]) - .getJGDSync() - .should.be.sameJGD(donutJGD(0x40404000, 0xff808088, 0xff8080ff)); + expectToBeJGD( + image.color([{ apply: "lighten", params: [25] }]).getJGDSync(), + donutJGD(0x40404000, 0xff808088, 0xff8080ff) + ); }); it("brighten", async () => { const image = await jimp.read(redDonutJGD); - image - .color([{ apply: "brighten", params: [25] }]) - .getJGDSync() - .should.be.sameJGD(donutJGD(0x40404000, 0xff404088, 0xff4040ff)); + expectToBeJGD( + image.color([{ apply: "brighten", params: [25] }]).getJGDSync(), + donutJGD(0x40404000, 0xff404088, 0xff4040ff) + ); }); it("spin hue", async () => { const image = await jimp.read(redDonutJGD); - image - .color([{ apply: "hue", params: [150] }]) - .getJGDSync() - .should.be.sameJGD(donutJGD(0x00000000, 0x00ff8088, 0x00ff80ff)); + expectToBeJGD( + image.color([{ apply: "hue", params: [150] }]).getJGDSync(), + donutJGD(0x00000000, 0x00ff8088, 0x00ff80ff) + ); }); }); diff --git a/packages/plugin-color/test/convolution.test.js b/packages/plugin-color/test/convolution.test.js index df64030a0..428ae52f3 100644 --- a/packages/plugin-color/test/convolution.test.js +++ b/packages/plugin-color/test/convolution.test.js @@ -1,8 +1,10 @@ import { Jimp, mkJGD, getTestDir } from "@jimp/test-utils"; import configure from "@jimp/custom"; import types from "@jimp/types"; +import expect from "@storybook/expect"; import color from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ types: [types], plugins: [color] }, Jimp); @@ -56,116 +58,95 @@ describe("Convolution", function () { ]; it("3x3 sharp matrix on EDGE_EXTEND", (done) => { - imgMid - .clone() - .convolution(sharpM) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "22222222", - "28EEE822", - "2EFFF802", - "2EF88002", - "2EF88002", - "28800002", - "22000002", - "22222222" - ), - "Mid light block" - ); - imgTopLeft - .clone() - .convolution(sharpM) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "80022222", - "00022222", - "00022222", - "22222222", - "22222222", - "22222222", - "22222222", - "22222222" - ), - "Top left light block" - ); + expectToBeJGD( + imgMid.clone().convolution(sharpM).getJGDSync(), + mkJGD( + "22222222", + "28EEE822", + "2EFFF802", + "2EF88002", + "2EF88002", + "28800002", + "22000002", + "22222222" + ) + ); + + expectToBeJGD( + imgTopLeft.clone().convolution(sharpM).getJGDSync(), + mkJGD( + "80022222", + "00022222", + "00022222", + "22222222", + "22222222", + "22222222", + "22222222", + "22222222" + ) + ); done(); }); it("3x3 sharp matrix on EDGE_WRAP", (done) => { - imgMid - .clone() - .convolution(sharpM, jimp.EDGE_WRAP) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "22222222", - "28EEE822", - "2EFFF802", - "2EF88002", - "2EF88002", - "28800002", - "22000002", - "22222222" - ), - "Mid light block" - ); - imgTopLeft - .clone() - .convolution(sharpM, jimp.EDGE_WRAP) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "F802222E", - "80022228", - "00022222", - "22222222", - "22222222", - "22222222", - "22222222", - "E8222228" - ), - "Top left light block" - ); + expectToBeJGD( + imgMid.clone().convolution(sharpM, jimp.EDGE_WRAP).getJGDSync(), + mkJGD( + "22222222", + "28EEE822", + "2EFFF802", + "2EF88002", + "2EF88002", + "28800002", + "22000002", + "22222222" + ) + ); + + expectToBeJGD( + imgTopLeft.clone().convolution(sharpM, jimp.EDGE_WRAP).getJGDSync(), + mkJGD( + "F802222E", + "80022228", + "00022222", + "22222222", + "22222222", + "22222222", + "22222222", + "E8222228" + ) + ); done(); }); it("3x3 sharp matrix on EDGE_CROP", (done) => { - imgMid - .clone() - .convolution(sharpM, jimp.EDGE_CROP) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "86666662", - "68EEE820", - "6EFFF800", - "6EF88000", - "6EF88000", - "68800000", - "62000000", - "20000000" - ), - "Mid light block" - ); - imgTopLeft - .clone() - .convolution(sharpM, jimp.EDGE_CROP) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "FC066662", - "C0022220", - "00022220", - "62222220", - "62222220", - "62222220", - "62222220", - "20000000" - ), - "Top left light block" - ); + expectToBeJGD( + imgMid.clone().convolution(sharpM, jimp.EDGE_CROP).getJGDSync(), + mkJGD( + "86666662", + "68EEE820", + "6EFFF800", + "6EF88000", + "6EF88000", + "68800000", + "62000000", + "20000000" + ) + ); + + expectToBeJGD( + imgTopLeft.clone().convolution(sharpM, jimp.EDGE_CROP).getJGDSync(), + mkJGD( + "FC066662", + "C0022220", + "00022220", + "62222220", + "62222220", + "62222220", + "62222220", + "20000000" + ) + ); done(); }); @@ -175,14 +156,14 @@ describe("Convolution", function () { ); const image = await jimp.read(getTestDir(__dirname) + "/images/qr.jpg"); - image - .convolution([ + expect( + image.convolution([ [0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0], - ]) - .bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + ]).bitmap.data + ).toEqual(expectedImg.bitmap.data); }); }); diff --git a/packages/plugin-contain/test/contain.test.js b/packages/plugin-contain/test/contain.test.js index 19739a277..43e0fb42e 100644 --- a/packages/plugin-contain/test/contain.test.js +++ b/packages/plugin-contain/test/contain.test.js @@ -5,6 +5,7 @@ import resize from "@jimp/plugin-resize"; import scale from "@jimp/plugin-scale"; import contain from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [scale, resize, blit, contain] }, Jimp); @@ -114,16 +115,14 @@ describe("All align combinations for contain", () => { let a = align.split(" "); a = Jimp["HORIZONTAL_ALIGN_" + a[0]] | Jimp["VERTICAL_ALIGN_" + a[1]]; it("contain aligned to " + align, () => { - vertical - .clone() - .contain(6, 6, a) - .getJGDSync() - .should.be.sameJGD(jgdContainV, "Vertical image"); - horizontal - .clone() - .contain(6, 6, a) - .getJGDSync() - .should.be.sameJGD(jgdContainH, "Horizontal image"); + expectToBeJGD( + vertical.clone().contain(6, 6, a).getJGDSync(), + jgdContainV + ); + expectToBeJGD( + horizontal.clone().contain(6, 6, a).getJGDSync(), + jgdContainH + ); }); } diff --git a/packages/plugin-cover/test/cover.test.js b/packages/plugin-cover/test/cover.test.js index 121fa4421..ba61d3bbf 100644 --- a/packages/plugin-cover/test/cover.test.js +++ b/packages/plugin-cover/test/cover.test.js @@ -5,6 +5,7 @@ import scale from "@jimp/plugin-scale"; import resize from "@jimp/plugin-resize"; import cover from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [resize, scale, crop, cover] }, Jimp); @@ -114,16 +115,8 @@ describe("All align combinations for cover", () => { let a = align.split(" "); a = Jimp["HORIZONTAL_ALIGN_" + a[0]] | Jimp["VERTICAL_ALIGN_" + a[1]]; it("cover aligned to " + align, () => { - vertical - .clone() - .cover(4, 4, a) - .getJGDSync() - .should.be.sameJGD(jgdCoverV, "Vertical image"); - horizontal - .clone() - .cover(4, 4, a) - .getJGDSync() - .should.be.sameJGD(jgdCoverH, "Horizontal image"); + expectToBeJGD(vertical.clone().cover(4, 4, a).getJGDSync(), jgdCoverV); + expectToBeJGD(horizontal.clone().cover(4, 4, a).getJGDSync(), jgdCoverH); }); } diff --git a/packages/plugin-crop/test/autocrop.test.js b/packages/plugin-crop/test/autocrop.test.js index 915fb7c9a..4905a317a 100644 --- a/packages/plugin-crop/test/autocrop.test.js +++ b/packages/plugin-crop/test/autocrop.test.js @@ -2,6 +2,7 @@ import { Jimp, mkJGD } from "@jimp/test-utils"; import configure from "@jimp/custom"; import crop from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [crop] }, Jimp); @@ -19,12 +20,10 @@ describe("Autocrop", () => { ) ); - imgSrc - .autocrop() - .getJGDSync() - .should.be.sameJGD( - mkJGD(" ◆◆ ", " ◆▦▦◆ ", "◆▦▦▦▦◆", " ◆▦▦◆ ", " ◆◆ ") - ); + expectToBeJGD( + imgSrc.autocrop().getJGDSync(), + mkJGD(" ◆◆ ", " ◆▦▦◆ ", "◆▦▦▦▦◆", " ◆▦▦◆ ", " ◆◆ ") + ); }); it("image with opaque surround color", async () => { @@ -40,12 +39,10 @@ describe("Autocrop", () => { ) ); - imgSrc - .autocrop() - .getJGDSync() - .should.be.sameJGD( - mkJGD("▥▥◆◆▥▥", "▥◆▦▦◆▥", "◆▦▦▦▦◆", "▥◆▦▦◆▥", "▥▥◆◆▥▥") - ); + expectToBeJGD( + imgSrc.autocrop().getJGDSync(), + mkJGD("▥▥◆◆▥▥", "▥◆▦▦◆▥", "◆▦▦▦▦◆", "▥◆▦▦◆▥", "▥▥◆◆▥▥") + ); }); it("image with one color border", async () => { @@ -63,12 +60,10 @@ describe("Autocrop", () => { ) ); - imgSrc - .autocrop() - .getJGDSync() - .should.be.sameJGD( - mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆ ", " ◆▦▦◆ ", " ◆◆ ") - ); + expectToBeJGD( + imgSrc.autocrop().getJGDSync(), + mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆ ", " ◆▦▦◆ ", " ◆◆ ") + ); }); it("image border with small variation", async () => { @@ -85,30 +80,24 @@ describe("Autocrop", () => { "323232323232" ) ); - imgSrc - .clone() - .autocrop() - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "323232323232", - "232323232323", - "32 ◆◆ 32", - "23 ◆▦▦◆ 23", - "32 ◆▦▦▦▦◆ 32", - "23 ◆▦▦◆ 23", - "32 ◆◆ 32", - "232323232323", - "323232323232" - ) - ); - imgSrc - .clone() - .autocrop(0.005) - .getJGDSync() - .should.be.sameJGD( - mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆ ", " ◆▦▦◆ ", " ◆◆ ") - ); + expectToBeJGD( + imgSrc.clone().autocrop().getJGDSync(), + mkJGD( + "323232323232", + "232323232323", + "32 ◆◆ 32", + "23 ◆▦▦◆ 23", + "32 ◆▦▦▦▦◆ 32", + "23 ◆▦▦◆ 23", + "32 ◆◆ 32", + "232323232323", + "323232323232" + ) + ); + expectToBeJGD( + imgSrc.clone().autocrop(0.005).getJGDSync(), + mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆ ", " ◆▦▦◆ ", " ◆◆ ") + ); }); it("image border with small variation configured by options", async () => { @@ -125,30 +114,24 @@ describe("Autocrop", () => { "323232323232" ) ); - imgSrc - .clone() - .autocrop() - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "323232323232", - "232323232323", - "32 ◆◆ 32", - "23 ◆▦▦◆ 23", - "32 ◆▦▦▦▦◆ 32", - "23 ◆▦▦◆ 23", - "32 ◆◆ 32", - "232323232323", - "323232323232" - ) - ); - imgSrc - .clone() - .autocrop({ tolerance: 0.005 }) - .getJGDSync() - .should.be.sameJGD( - mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆ ", " ◆▦▦◆ ", " ◆◆ ") - ); + expectToBeJGD( + imgSrc.clone().autocrop().getJGDSync(), + mkJGD( + "323232323232", + "232323232323", + "32 ◆◆ 32", + "23 ◆▦▦◆ 23", + "32 ◆▦▦▦▦◆ 32", + "23 ◆▦▦◆ 23", + "32 ◆◆ 32", + "232323232323", + "323232323232" + ) + ); + expectToBeJGD( + imgSrc.clone().autocrop({ tolerance: 0.005 }).getJGDSync(), + mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆ ", " ◆▦▦◆ ", " ◆◆ ") + ); }); it("image without frame", async () => { @@ -164,12 +147,10 @@ describe("Autocrop", () => { ) ); - imgSrc - .autocrop(false) - .getJGDSync() - .should.be.sameJGD( - mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆ ", " ◆▦▦◆ ", " ◆◆ ") - ); + expectToBeJGD( + imgSrc.autocrop(false).getJGDSync(), + mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆ ", " ◆▦▦◆ ", " ◆◆ ") + ); }); it("image without frame configured by options", async () => { @@ -185,12 +166,10 @@ describe("Autocrop", () => { ) ); - imgSrc - .autocrop({ cropOnlyFrames: false }) - .getJGDSync() - .should.be.sameJGD( - mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆ ", " ◆▦▦◆ ", " ◆◆ ") - ); + expectToBeJGD( + imgSrc.autocrop({ cropOnlyFrames: false }).getJGDSync(), + mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆ ", " ◆▦▦◆ ", " ◆◆ ") + ); }); it("image with symmetric border configured by options", async () => { @@ -207,19 +186,17 @@ describe("Autocrop", () => { ) ); - imgSrc - .autocrop({ cropSymmetric: true }) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ◆◆ ▥▥", - " ◆▦▦◆ ▥▥", - " ◆▦▦▦▦◆ ▥▥", - " ◆▦▦◆ ▥▥", - " ◆◆ ▥▥", - "▥▥▥▥▥▥▥▥▥▥" - ) - ); + expectToBeJGD( + imgSrc.autocrop({ cropSymmetric: true }).getJGDSync(), + mkJGD( + " ◆◆ ▥▥", + " ◆▦▦◆ ▥▥", + " ◆▦▦▦▦◆ ▥▥", + " ◆▦▦◆ ▥▥", + " ◆◆ ▥▥", + "▥▥▥▥▥▥▥▥▥▥" + ) + ); }); it("image without frame and with symmetric border configured by options", async () => { @@ -234,20 +211,20 @@ describe("Autocrop", () => { "▥▥▥▥▥▥▥▥▥▥▥▥▥▥" ) ); - imgSrc - .autocrop({ cropSymmetric: true, cropOnlyFrames: false }) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ◆◆ ▥▥", - " ◆▦▦◆ ▥▥", - " ◆▦▦▦▦◆ ▥▥", - " ◆▦▦◆ ▥▥", - " ◆◆ ▥▥", - "▥▥▥▥▥▥▥▥▥▥", - "▥▥▥▥▥▥▥▥▥▥" - ) - ); + expectToBeJGD( + imgSrc + .autocrop({ cropSymmetric: true, cropOnlyFrames: false }) + .getJGDSync(), + mkJGD( + " ◆◆ ▥▥", + " ◆▦▦◆ ▥▥", + " ◆▦▦▦▦◆ ▥▥", + " ◆▦▦◆ ▥▥", + " ◆◆ ▥▥", + "▥▥▥▥▥▥▥▥▥▥", + "▥▥▥▥▥▥▥▥▥▥" + ) + ); }); it("image without frame and with some border left", async () => { @@ -265,23 +242,23 @@ describe("Autocrop", () => { ) ); - imgSrc - .autocrop({ - tolerance: 0.005, - leaveBorder: 1, - }) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "3232323232", - "2 ◆◆ 3", - "3 ◆▦▦◆ 2", - "2 ◆▦▦▦▦◆ 3", - "3 ◆▦▦◆ 2", - "2 ◆◆ 3", - "3232323232" - ) - ); + expectToBeJGD( + imgSrc + .autocrop({ + tolerance: 0.005, + leaveBorder: 1, + }) + .getJGDSync(), + mkJGD( + "3232323232", + "2 ◆◆ 3", + "3 ◆▦▦◆ 2", + "2 ◆▦▦▦▦◆ 3", + "3 ◆▦▦◆ 2", + "2 ◆◆ 3", + "3232323232" + ) + ); }); it('image not cropped given an out of bounds "leaveBorder" value ', async () => { @@ -298,26 +275,25 @@ describe("Autocrop", () => { "323232323232" ) ); - - imgSrc - .autocrop({ - tolerance: 0.005, - leaveBorder: 100, - }) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "323232323232", - "232323232323", - "32 ◆◆ 32", - "23 ◆▦▦◆ 23", - "32 ◆▦▦▦▦◆ 32", - "23 ◆▦▦◆ 23", - "32 ◆◆ 32", - "232323232323", - "323232323232" - ) - ); + expectToBeJGD( + imgSrc + .autocrop({ + tolerance: 0.005, + leaveBorder: 100, + }) + .getJGDSync(), + mkJGD( + "323232323232", + "232323232323", + "32 ◆◆ 32", + "23 ◆▦▦◆ 23", + "32 ◆▦▦▦▦◆ 32", + "23 ◆▦▦◆ 23", + "32 ◆◆ 32", + "232323232323", + "323232323232" + ) + ); }); it("image with top and bottom frame and leaveBorder", async () => { @@ -336,22 +312,26 @@ describe("Autocrop", () => { "▥▥▥▥▥▥▥▥" ) ); - imgSrc - .autocrop({ cropSymmetric: true, cropOnlyFrames: false, leaveBorder: 2 }) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "▥▥▥▥▥▥▥▥", - "▥▥▥▥▥▥▥▥", - " ◆◆ ", - " ◆▦▦◆ ", - " ◆▦▦▦▦◆ ", - " ◆▦▦◆ ", - " ◆◆ ", - "▥▥▥▥▥▥▥▥", - "▥▥▥▥▥▥▥▥" - ) - ); + expectToBeJGD( + imgSrc + .autocrop({ + cropSymmetric: true, + cropOnlyFrames: false, + leaveBorder: 2, + }) + .getJGDSync(), + mkJGD( + "▥▥▥▥▥▥▥▥", + "▥▥▥▥▥▥▥▥", + " ◆◆ ", + " ◆▦▦◆ ", + " ◆▦▦▦▦◆ ", + " ◆▦▦◆ ", + " ◆◆ ", + "▥▥▥▥▥▥▥▥", + "▥▥▥▥▥▥▥▥" + ) + ); }); it("ignore sides north", async () => { @@ -366,13 +346,12 @@ describe("Autocrop", () => { " " ) ); - - imgSrc - .autocrop({ cropOnlyFrames: false, ignoreSides: { north: true } }) - .getJGDSync() - .should.be.sameJGD( - mkJGD(" ", " ◆◆ ", " ◆▦▦◆ ", "◆▦▦▦▦◆", " ◆▦▦◆ ", " ◆◆ ") - ); + expectToBeJGD( + imgSrc + .autocrop({ cropOnlyFrames: false, ignoreSides: { north: true } }) + .getJGDSync(), + mkJGD(" ", " ◆◆ ", " ◆▦▦◆ ", "◆▦▦▦▦◆", " ◆▦▦◆ ", " ◆◆ ") + ); }); it("ignore sides south and west", async () => { @@ -388,22 +367,22 @@ describe("Autocrop", () => { ) ); - imgSrc - .autocrop({ - cropOnlyFrames: false, - ignoreSides: { west: true, south: true }, - }) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ◆◆ ", - " ◆▦▦◆ ", - "◆▦▦▦▦◆ ", - " ◆▦▦◆ ", - " ◆◆ ", - " " - ) - ); + expectToBeJGD( + imgSrc + .autocrop({ + cropOnlyFrames: false, + ignoreSides: { west: true, south: true }, + }) + .getJGDSync(), + mkJGD( + " ◆◆ ", + " ◆▦▦◆ ", + "◆▦▦▦▦◆ ", + " ◆▦▦◆ ", + " ◆◆ ", + " " + ) + ); }); it("ignore sides east", async () => { @@ -419,11 +398,11 @@ describe("Autocrop", () => { ) ); - imgSrc - .autocrop({ cropOnlyFrames: false, ignoreSides: { east: true } }) - .getJGDSync() - .should.be.sameJGD( - mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆", " ◆▦▦◆ ", " ◆◆ ") - ); + expectToBeJGD( + imgSrc + .autocrop({ cropOnlyFrames: false, ignoreSides: { east: true } }) + .getJGDSync(), + mkJGD(" ◆◆ ", " ◆▦▦◆ ", " ◆▦▦▦▦◆", " ◆▦▦◆ ", " ◆◆ ") + ); }); }); diff --git a/packages/plugin-crop/test/crop.test.js b/packages/plugin-crop/test/crop.test.js index 734e2788d..a6bb50026 100644 --- a/packages/plugin-crop/test/crop.test.js +++ b/packages/plugin-crop/test/crop.test.js @@ -2,6 +2,7 @@ import { Jimp, mkJGD } from "@jimp/test-utils"; import configure from "@jimp/custom"; import crop from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [crop] }, Jimp); @@ -12,54 +13,54 @@ describe("crop", () => { it("full width from top", async () => { const imgSrc = await jimp.read(testImage); - imgSrc - .crop(0, 0, 6, 2) - .getJGDSync() - .should.be.sameJGD(mkJGD(" ◆◆ ", " ◆▦▦◆ ")); + expectToBeJGD( + imgSrc.crop(0, 0, 6, 2).getJGDSync(), + mkJGD(" ◆◆ ", " ◆▦▦◆ ") + ); }); it("full width from bottom", async () => { const imgSrc = await jimp.read(testImage); - imgSrc - .crop(0, 3, 6, 2) - .getJGDSync() - .should.be.sameJGD(mkJGD(" ◆▦▦◆ ", " ◆◆ ")); + expectToBeJGD( + imgSrc.crop(0, 3, 6, 2).getJGDSync(), + mkJGD(" ◆▦▦◆ ", " ◆◆ ") + ); }); it("full width from middle", async () => { const imgSrc = await jimp.read(testImage); - imgSrc - .crop(0, 2, 6, 2) - .getJGDSync() - .should.be.sameJGD(mkJGD("◆▦▦▦▦◆", " ◆▦▦◆ ")); + expectToBeJGD( + imgSrc.crop(0, 2, 6, 2).getJGDSync(), + mkJGD("◆▦▦▦▦◆", " ◆▦▦◆ ") + ); }); it("full height from left", async () => { const imgSrc = await jimp.read(testImage); - imgSrc - .crop(0, 0, 2, 5) - .getJGDSync() - .should.be.sameJGD(mkJGD(" ", " ◆", "◆▦", " ◆", " ")); + expectToBeJGD( + imgSrc.crop(0, 0, 2, 5).getJGDSync(), + mkJGD(" ", " ◆", "◆▦", " ◆", " ") + ); }); it("full height from right", async () => { const imgSrc = await jimp.read(testImage); - imgSrc - .crop(4, 0, 2, 5) - .getJGDSync() - .should.be.sameJGD(mkJGD(" ", "◆ ", "▦◆", "◆ ", " ")); + expectToBeJGD( + imgSrc.crop(4, 0, 2, 5).getJGDSync(), + mkJGD(" ", "◆ ", "▦◆", "◆ ", " ") + ); }); it("full height from middle", async () => { const imgSrc = await jimp.read(testImage); - imgSrc - .crop(2, 0, 2, 5) - .getJGDSync() - .should.be.sameJGD(mkJGD("◆◆", "▦▦", "▦▦", "▦▦", "◆◆")); + expectToBeJGD( + imgSrc.crop(2, 0, 2, 5).getJGDSync(), + mkJGD("◆◆", "▦▦", "▦▦", "▦▦", "◆◆") + ); }); }); diff --git a/packages/plugin-fisheye/test/fisheye.test.js b/packages/plugin-fisheye/test/fisheye.test.js index b8f5aa1e6..537b4f452 100644 --- a/packages/plugin-fisheye/test/fisheye.test.js +++ b/packages/plugin-fisheye/test/fisheye.test.js @@ -2,6 +2,7 @@ import { Jimp, mkJGD } from "@jimp/test-utils"; import configure from "@jimp/custom"; import fisheye from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [fisheye] }, Jimp); @@ -36,7 +37,7 @@ describe("Fisheye", () => { ) ); - imgNormal.fisheye().getJGDSync().should.be.sameJGD(imgBulged.getJGDSync()); + expectToBeJGD(imgNormal.fisheye().getJGDSync(), imgBulged.getJGDSync()); }); it("should create fisheye lens to image with radius", async () => { @@ -69,9 +70,9 @@ describe("Fisheye", () => { ) ); - imgNormal - .fisheye({ r: 1.8 }) - .getJGDSync() - .should.be.sameJGD(imgBulged.getJGDSync()); + expectToBeJGD( + imgNormal.fisheye({ r: 1.8 }).getJGDSync(), + imgBulged.getJGDSync() + ); }); }); diff --git a/packages/plugin-flip/test/flipping.test.js b/packages/plugin-flip/test/flipping.test.js index fb17d2032..6866acf60 100644 --- a/packages/plugin-flip/test/flipping.test.js +++ b/packages/plugin-flip/test/flipping.test.js @@ -3,6 +3,7 @@ import { Jimp, mkJGD } from "@jimp/test-utils"; import configure from "@jimp/custom"; import flip from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [flip] }, Jimp); @@ -22,19 +23,18 @@ describe("Flipping plugin", () => { const result = src.flip(true, false); - result - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "BBBBAAAA", - "BAAABAAA", - "BABABABA", - "CCCCCCCC", - "CCCCCCCC", - "CCCCCCCC", - "AACCCCAA" - ) - ); + expectToBeJGD( + result.getJGDSync(), + mkJGD( + "BBBBAAAA", + "BAAABAAA", + "BABABABA", + "CCCCCCCC", + "CCCCCCCC", + "CCCCCCCC", + "AACCCCAA" + ) + ); }); it("can flip vertically", async () => { @@ -52,19 +52,18 @@ describe("Flipping plugin", () => { const result = src.flip(false, true); - result - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "AACCCCAA", - "CCCCCCCC", - "CCCCCCCC", - "CCCCCCCC", - "ABABABAB", - "AAABAAAB", - "AAAABBBB" - ) - ); + expectToBeJGD( + result.getJGDSync(), + mkJGD( + "AACCCCAA", + "CCCCCCCC", + "CCCCCCCC", + "CCCCCCCC", + "ABABABAB", + "AAABAAAB", + "AAAABBBB" + ) + ); }); it("can flip both horizontally and vertically at once", async () => { @@ -82,18 +81,17 @@ describe("Flipping plugin", () => { const result = src.flip(true, true); - result - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "AACCCCAA", - "CCCCCCCC", - "CCCCCCCC", - "CCCCCCCC", - "BABABABA", - "BAAABAAA", - "BBBBAAAA" - ) - ); + expectToBeJGD( + result.getJGDSync(), + mkJGD( + "AACCCCAA", + "CCCCCCCC", + "CCCCCCCC", + "CCCCCCCC", + "BABABABA", + "BAAABAAA", + "BBBBAAAA" + ) + ); }); }); diff --git a/packages/plugin-mask/test/mask.test.js b/packages/plugin-mask/test/mask.test.js index 373bc099e..e63713f60 100644 --- a/packages/plugin-mask/test/mask.test.js +++ b/packages/plugin-mask/test/mask.test.js @@ -2,6 +2,7 @@ import { Jimp, mkJGD } from "@jimp/test-utils"; import configure from "@jimp/custom"; import mask from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [mask] }, Jimp); @@ -32,142 +33,102 @@ describe("Mask", () => { }); it("Affect opaque image with a gray mask with the same size", () => { - imgSrcOpaq - .clone() - .mask(maskGrayBig) - .getJGDSync() - .should.be.sameJGD({ - width: 6, - height: 4, - data: [ - 0xff000000, 0xffffff44, 0x0000ff88, 0xffffff88, 0x00000044, - 0xffffff00, 0x00000088, 0xff0000cc, 0x000000ff, 0x0000ffff, - 0x000000cc, 0xffffff88, 0x00000088, 0xffffffcc, 0xff0000ff, - 0xffffffff, 0x0000ffcc, 0xffffff88, 0x00000000, 0xffffff44, - 0x00000088, 0xff000088, 0x00000044, 0x0000ff00, - ], - }); + expectToBeJGD(imgSrcOpaq.clone().mask(maskGrayBig).getJGDSync(), { + width: 6, + height: 4, + data: [ + 0xff000000, 0xffffff44, 0x0000ff88, 0xffffff88, 0x00000044, 0xffffff00, + 0x00000088, 0xff0000cc, 0x000000ff, 0x0000ffff, 0x000000cc, 0xffffff88, + 0x00000088, 0xffffffcc, 0xff0000ff, 0xffffffff, 0x0000ffcc, 0xffffff88, + 0x00000000, 0xffffff44, 0x00000088, 0xff000088, 0x00000044, 0x0000ff00, + ], + }); }); it("Affect opaque image with a gray mask with the same size, blited", () => { - imgSrcOpaq - .clone() - .mask(maskGrayBig, 1, 1) - .getJGDSync() - .should.be.sameJGD({ - width: 6, - height: 4, - data: [ - 0xff0000ff, 0xffffffff, 0x0000ffff, 0xffffffff, 0x000000ff, - 0xffffffff, 0x000000ff, 0xff000000, 0x00000044, 0x0000ff88, - 0x00000088, 0xffffff44, 0x000000ff, 0xffffff88, 0xff0000cc, - 0xffffffff, 0x0000ffff, 0xffffffcc, 0x000000ff, 0xffffff88, - 0x000000cc, 0xff0000ff, 0x000000ff, 0x0000ffcc, - ], - }); + expectToBeJGD(imgSrcOpaq.clone().mask(maskGrayBig, 1, 1).getJGDSync(), { + width: 6, + height: 4, + data: [ + 0xff0000ff, 0xffffffff, 0x0000ffff, 0xffffffff, 0x000000ff, 0xffffffff, + 0x000000ff, 0xff000000, 0x00000044, 0x0000ff88, 0x00000088, 0xffffff44, + 0x000000ff, 0xffffff88, 0xff0000cc, 0xffffffff, 0x0000ffff, 0xffffffcc, + 0x000000ff, 0xffffff88, 0x000000cc, 0xff0000ff, 0x000000ff, 0x0000ffcc, + ], + }); }); it("Affect opaque image with a gray mask with the same size, blited negative", () => { - imgSrcOpaq - .clone() - .mask(maskGrayBig, -1, -1) - .getJGDSync() - .should.be.sameJGD({ - width: 6, - height: 4, - data: [ - 0xff0000cc, 0xffffffff, 0x0000ffff, 0xffffffcc, 0x00000088, - 0xffffffff, 0x000000cc, 0xff0000ff, 0x000000ff, 0x0000ffcc, - 0x00000088, 0xffffffff, 0x00000044, 0xffffff88, 0xff000088, - 0xffffff44, 0x0000ff00, 0xffffffff, 0x000000ff, 0xffffffff, - 0x000000ff, 0xff0000ff, 0x000000ff, 0x0000ffff, - ], - }); + expectToBeJGD(imgSrcOpaq.clone().mask(maskGrayBig, -1, -1).getJGDSync(), { + width: 6, + height: 4, + data: [ + 0xff0000cc, 0xffffffff, 0x0000ffff, 0xffffffcc, 0x00000088, 0xffffffff, + 0x000000cc, 0xff0000ff, 0x000000ff, 0x0000ffcc, 0x00000088, 0xffffffff, + 0x00000044, 0xffffff88, 0xff000088, 0xffffff44, 0x0000ff00, 0xffffffff, + 0x000000ff, 0xffffffff, 0x000000ff, 0xff0000ff, 0x000000ff, 0x0000ffff, + ], + }); }); it("Affect opaque image with a smaller gray mask", () => { - imgSrcOpaq - .clone() - .mask(maskGraySmall) - .getJGDSync() - .should.be.sameJGD({ - width: 6, - height: 4, - data: [ - 0xff000000, 0xffffff33, 0x0000ff66, 0xffffff99, 0x000000ff, - 0xffffffff, 0x00000033, 0xff000066, 0x00000099, 0x0000ffcc, - 0x000000ff, 0xffffffff, 0x00000066, 0xffffff99, 0xff0000cc, - 0xffffffff, 0x0000ffff, 0xffffffff, 0x000000ff, 0xffffffff, - 0x000000ff, 0xff0000ff, 0x000000ff, 0x0000ffff, - ], - }); + expectToBeJGD(imgSrcOpaq.clone().mask(maskGraySmall).getJGDSync(), { + width: 6, + height: 4, + data: [ + 0xff000000, 0xffffff33, 0x0000ff66, 0xffffff99, 0x000000ff, 0xffffffff, + 0x00000033, 0xff000066, 0x00000099, 0x0000ffcc, 0x000000ff, 0xffffffff, + 0x00000066, 0xffffff99, 0xff0000cc, 0xffffffff, 0x0000ffff, 0xffffffff, + 0x000000ff, 0xffffffff, 0x000000ff, 0xff0000ff, 0x000000ff, 0x0000ffff, + ], + }); }); it("Affect opaque image with a smaller gray mask, blited", () => { - imgSrcOpaq - .clone() - .mask(maskGraySmall, 1, 1) - .getJGDSync() - .should.be.sameJGD({ - width: 6, - height: 4, - data: [ - 0xff0000ff, 0xffffffff, 0x0000ffff, 0xffffffff, 0x000000ff, - 0xffffffff, 0x000000ff, 0xff000000, 0x00000033, 0x0000ff66, - 0x00000099, 0xffffffff, 0x000000ff, 0xffffff33, 0xff000066, - 0xffffff99, 0x0000ffcc, 0xffffffff, 0x000000ff, 0xffffff66, - 0x00000099, 0xff0000cc, 0x000000ff, 0x0000ffff, - ], - }); + expectToBeJGD(imgSrcOpaq.clone().mask(maskGraySmall, 1, 1).getJGDSync(), { + width: 6, + height: 4, + data: [ + 0xff0000ff, 0xffffffff, 0x0000ffff, 0xffffffff, 0x000000ff, 0xffffffff, + 0x000000ff, 0xff000000, 0x00000033, 0x0000ff66, 0x00000099, 0xffffffff, + 0x000000ff, 0xffffff33, 0xff000066, 0xffffff99, 0x0000ffcc, 0xffffffff, + 0x000000ff, 0xffffff66, 0x00000099, 0xff0000cc, 0x000000ff, 0x0000ffff, + ], + }); }); it("Affect alpha image with a bigger gray mask", () => { - imgSrcAlpa - .clone() - .mask(maskGrayBig) - .getJGDSync() - .should.be.sameJGD({ - width: 4, - height: 3, - data: [ - 0xff000000, 0xff000021, 0x0000ff88, 0x0000ff43, 0xff000088, - 0xff000065, 0x0000ffff, 0x0000ff7f, 0xff000088, 0xff000065, - 0x0000ffff, 0x0000ff7f, - ], - }); + expectToBeJGD(imgSrcAlpa.clone().mask(maskGrayBig).getJGDSync(), { + width: 4, + height: 3, + data: [ + 0xff000000, 0xff000021, 0x0000ff88, 0x0000ff43, 0xff000088, 0xff000065, + 0x0000ffff, 0x0000ff7f, 0xff000088, 0xff000065, 0x0000ffff, 0x0000ff7f, + ], + }); }); it("Affect alpha image with a bigger gray mask, blited", () => { - imgSrcAlpa - .clone() - .mask(maskGrayBig, -1, -1) - .getJGDSync() - .should.be.sameJGD({ - width: 4, - height: 3, - data: [ - 0xff0000cc, 0xff00007f, 0x0000ffff, 0x0000ff65, 0xff0000cc, - 0xff00007f, 0x0000ffff, 0x0000ff65, 0xff000044, 0xff000043, - 0x0000ff88, 0x0000ff21, - ], - }); + expectToBeJGD(imgSrcAlpa.clone().mask(maskGrayBig, -1, -1).getJGDSync(), { + width: 4, + height: 3, + data: [ + 0xff0000cc, 0xff00007f, 0x0000ffff, 0x0000ff65, 0xff0000cc, 0xff00007f, + 0x0000ffff, 0x0000ff65, 0xff000044, 0xff000043, 0x0000ff88, 0x0000ff21, + ], + }); }); it("Affect opaque image with a colored mask", () => { - imgSrcOpaq - .clone() - .mask(maskColor, 1, 1) - .getJGDSync() - .should.be.sameJGD({ - width: 6, - height: 4, - data: [ - 0xff0000ff, 0xffffffff, 0x0000ffff, 0xffffffff, 0x000000ff, - 0xffffffff, 0x000000ff, 0xff000055, 0x00000055, 0x0000ff55, - 0x00000055, 0xffffffff, 0x000000ff, 0xffffffaa, 0xff0000aa, - 0xffffffaa, 0x0000ffaa, 0xffffffff, 0x000000ff, 0xffffffff, - 0x000000ff, 0xff0000ff, 0x000000ff, 0x0000ffff, - ], - }); + expectToBeJGD(imgSrcOpaq.clone().mask(maskColor, 1, 1).getJGDSync(), { + width: 6, + height: 4, + data: [ + 0xff0000ff, 0xffffffff, 0x0000ffff, 0xffffffff, 0x000000ff, 0xffffffff, + 0x000000ff, 0xff000055, 0x00000055, 0x0000ff55, 0x00000055, 0xffffffff, + 0x000000ff, 0xffffffaa, 0xff0000aa, 0xffffffaa, 0x0000ffaa, 0xffffffff, + 0x000000ff, 0xffffffff, 0x000000ff, 0xff0000ff, 0x000000ff, 0x0000ffff, + ], + }); }); }); diff --git a/packages/plugin-normalize/test/normalize.test.js b/packages/plugin-normalize/test/normalize.test.js index fc67fec76..2d8a885a7 100644 --- a/packages/plugin-normalize/test/normalize.test.js +++ b/packages/plugin-normalize/test/normalize.test.js @@ -2,6 +2,7 @@ import { Jimp, mkJGD } from "@jimp/test-utils"; import configure from "@jimp/custom"; import normalize from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [normalize] }, Jimp); @@ -9,10 +10,7 @@ describe("Normalize", () => { it("change grayscale image", async () => { const image = await jimp.read(mkJGD("36▦", "6▦9", "▦9C")); - image - .normalize() - .getJGDSync() - .should.be.sameJGD(mkJGD("■5▦", "5▦A", "▦A□")); + expectToBeJGD(image.normalize().getJGDSync(), mkJGD("■5▦", "5▦A", "▦A□")); }); it("change red/blue image", async () => { @@ -24,16 +22,12 @@ describe("Normalize", () => { ], }); - image - .normalize() - .getJGDSync() - .should.be.sameJGD({ - width: 3, - height: 2, - data: [ - 0x000000ff, 0x7f0066ff, 0x7f006600, 0x7f0000ff, 0x000066ff, - 0xff00ffff, - ], - }); + expectToBeJGD(image.normalize().getJGDSync(), { + width: 3, + height: 2, + data: [ + 0x000000ff, 0x7f0066ff, 0x7f006600, 0x7f0000ff, 0x000066ff, 0xff00ffff, + ], + }); }); }); diff --git a/packages/plugin-print/test/print.test.js b/packages/plugin-print/test/print.test.js index fab5b7bcf..691329f55 100644 --- a/packages/plugin-print/test/print.test.js +++ b/packages/plugin-print/test/print.test.js @@ -3,6 +3,7 @@ import { Jimp, getTestDir, hasOwnProp } from "@jimp/test-utils"; import configure from "@jimp/custom"; import blit from "@jimp/plugin-blit"; +import expect from "@storybook/expect"; import print from "../src"; @@ -48,9 +49,10 @@ describe("Write text over image", function () { const expectedImg = await Jimp.read(expected); const image = await Jimp.create(conf.w, conf.h, conf.bg); - image - .print(font, 0, 0, "This is only a test.", image.bitmap.width) - .bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + expect( + image.print(font, 0, 0, "This is only a test.", image.bitmap.width) + .bitmap.data + ).toEqual(expectedImg.bitmap.data); }); })(fontName, fontDefs[fontName]); @@ -61,9 +63,9 @@ describe("Write text over image", function () { const expectedImg = await Jimp.read(expected); const image = await Jimp.create("300", "100", 0xff8800ff); - image - .print(font, 150, 50, "This is only a test.", 100) - .bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + expect( + image.print(font, 150, 50, "This is only a test.", 100).bitmap.data + ).toEqual(expectedImg.bitmap.data); }); it("Jimp loads font from URL", async () => { @@ -75,9 +77,9 @@ describe("Write text over image", function () { const expectedImg = await Jimp.read(expected); const image = await Jimp.create("300", "100", 0xff8800ff); - image - .print(font, 150, 50, "This is only a test.", 100) - .bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + expect( + image.print(font, 150, 50, "This is only a test.", 100).bitmap.data + ).toEqual(expectedImg.bitmap.data); }); it("Jimp renders ? for unknown characters", async () => { @@ -87,9 +89,9 @@ describe("Write text over image", function () { const expectedImg = await Jimp.read(expected); const image = await Jimp.read("300", "100", 0xff8800ff); - image - .print(font, 0, 0, "ツ ツ ツ", 100) - .bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + expect(image.print(font, 0, 0, "ツ ツ ツ", 100).bitmap.data).toEqual( + expectedImg.bitmap.data + ); }); it("Jimp can print numbers too", async () => { @@ -99,9 +101,9 @@ describe("Write text over image", function () { const expectedImg = await Jimp.read(expected); const image = await Jimp.read("300", "100", 0xff8800ff); - image - .print(font, 0, 0, 12345678, 100) - .bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + expect(image.print(font, 0, 0, 12345678, 100).bitmap.data).toEqual( + expectedImg.bitmap.data + ); }); it("left-align text by default", async () => { @@ -114,7 +116,7 @@ describe("Write text over image", function () { maxWidth: 100, }); - expectedImage.bitmap.data.should.be.deepEqual(textImage.bitmap.data); + expect(textImage.bitmap.data).toEqual(expectedImage.bitmap.data); }); it("left-align text by default when passing object", async () => { @@ -127,7 +129,7 @@ describe("Write text over image", function () { maxWidth: 100, }); - expectedImage.bitmap.data.should.be.deepEqual(textImage.bitmap.data); + expect(textImage.bitmap.data).toEqual(expectedImage.bitmap.data); }); it("left-align text when passing object with alignmentX", async () => { @@ -143,7 +145,7 @@ describe("Write text over image", function () { maxWidth: 100, }); - expectedImage.bitmap.data.should.be.deepEqual(textImage.bitmap.data); + expect(textImage.bitmap.data).toEqual(expectedImage.bitmap.data); }); it("center-align text when passing object with alignmentX", async () => { @@ -159,7 +161,7 @@ describe("Write text over image", function () { maxWidth: 100, }); - expectedImage.bitmap.data.should.be.deepEqual(textImage.bitmap.data); + expect(textImage.bitmap.data).toEqual(expectedImage.bitmap.data); }); it("right-align text when passing object with alignmentX", async () => { @@ -175,7 +177,7 @@ describe("Write text over image", function () { maxWidth: 100, }); - expectedImage.bitmap.data.should.be.deepEqual(textImage.bitmap.data); + expect(textImage.bitmap.data).toEqual(expectedImage.bitmap.data); }); it("middle-align text when passing object with alignmentY", async () => { @@ -193,7 +195,7 @@ describe("Write text over image", function () { maxHeight: 240, }); - expectedImage.bitmap.data.should.be.deepEqual(textImage.bitmap.data); + expect(textImage.bitmap.data).toEqual(expectedImage.bitmap.data); }); it("middle-align text when passing object with alignmentY can offset y", async () => { @@ -213,7 +215,7 @@ describe("Write text over image", function () { maxHeight: 240, }); - expectedImage.bitmap.data.should.be.deepEqual(textImage.bitmap.data); + expect(textImage.bitmap.data).toEqual(expectedImage.bitmap.data); }); it("bottom-align text when passing object with alignmentY", async () => { @@ -231,7 +233,7 @@ describe("Write text over image", function () { maxHeight: 240, }); - expectedImage.bitmap.data.should.be.deepEqual(textImage.bitmap.data); + expect(textImage.bitmap.data).toEqual(expectedImage.bitmap.data); }); it("bottom-align text when passing object with alignmentY offset y", async () => { @@ -251,7 +253,7 @@ describe("Write text over image", function () { maxHeight: 100, }); - expectedImage.bitmap.data.should.be.deepEqual(textImage.bitmap.data); + expect(textImage.bitmap.data).toEqual(expectedImage.bitmap.data); }); it("exposes print y position in cb", async () => { @@ -279,7 +281,7 @@ describe("Write text over image", function () { } ); - expectedImage.bitmap.data.should.be.deepEqual(image.bitmap.data); + expect(image.bitmap.data).toEqual(expectedImage.bitmap.data); }); it("measureText is consistent with measureTextWidth", async () => { @@ -290,6 +292,6 @@ describe("Write text over image", function () { const height = jimp.measureTextHeight(font, text, width); const lineHeight = jimp.measureTextHeight(font, text, Infinity); - height.should.be.deepEqual(lineHeight); + expect(height).toEqual(lineHeight); }); }); diff --git a/packages/plugin-resize/test/resize.test.js b/packages/plugin-resize/test/resize.test.js index 7f759084b..5a6d1c40d 100644 --- a/packages/plugin-resize/test/resize.test.js +++ b/packages/plugin-resize/test/resize.test.js @@ -2,6 +2,7 @@ import { Jimp, mkJGD, hashForEach } from "@jimp/test-utils"; import configure from "@jimp/custom"; import resize from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [resize] }, Jimp); @@ -287,11 +288,10 @@ describe("Resize images", () => { .split("x") .map((n) => parseInt(n, 10)); it("to " + expectedTitle, () => { - test.src - .clone() - .resize(size[0], size[1], mode) - .getJGDSync() - .should.be.sameJGD(expectedJgd); + expectToBeJGD( + test.src.clone().resize(size[0], size[1], mode).getJGDSync(), + expectedJgd + ); }); }); }); diff --git a/packages/plugin-rotate/test/rotation.test.js b/packages/plugin-rotate/test/rotation.test.js index c86db73fb..ca6ec27a1 100644 --- a/packages/plugin-rotate/test/rotation.test.js +++ b/packages/plugin-rotate/test/rotation.test.js @@ -5,6 +5,7 @@ import crop from "@jimp/plugin-crop"; import resize from "@jimp/plugin-resize"; import rotate from "../src"; +import { expectToBeJGD } from "@jimp/test-utils/src"; const jimp = configure({ plugins: [rotate, blit, crop, resize] }, Jimp); @@ -33,298 +34,259 @@ describe("Rotate a image with even size", () => { }); it("1 degrees", () => { - imgSrc - .clone() - .rotate(1, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "▰▴▴▴▪▪▪▰ ", - "▴▴▴▴▪▪▪▪ ", - "▴▴▴▴▪▪▪▪ ", - "▴▴▴▴▪▪▪▪ ", - "▪▪▪▪▴▴▴▴ ", - "▪▪▪▪▴▴▴▴ ", - "▪▪▪▪▴▴▴▴ ", - "▦▪▪▪▴▴▴▦ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(1, true).getJGDSync(), + mkJGD( + "▰▴▴▴▪▪▪▰ ", + "▴▴▴▴▪▪▪▪ ", + "▴▴▴▴▪▪▪▪ ", + "▴▴▴▴▪▪▪▪ ", + "▪▪▪▪▴▴▴▴ ", + "▪▪▪▪▴▴▴▴ ", + "▪▪▪▪▴▴▴▴ ", + "▦▪▪▪▴▴▴▦ ", + " ", + " " + ) + ); }); it("91 degrees", () => { - imgSrc - .clone() - .rotate(91, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - "▰▪▪▪▴▴▴▦ ", - "▪▪▪▪▴▴▴▴ ", - "▪▪▪▪▴▴▴▴ ", - "▪▪▪▪▴▴▴▴ ", - "▴▴▴▴▪▪▪▪ ", - "▴▴▴▴▪▪▪▪ ", - "▴▴▴▴▪▪▪▪ ", - "▰▴▴▴▪▪▪▦ ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(91, true).getJGDSync(), + mkJGD( + " ", + "▰▪▪▪▴▴▴▦ ", + "▪▪▪▪▴▴▴▴ ", + "▪▪▪▪▴▴▴▴ ", + "▪▪▪▪▴▴▴▴ ", + "▴▴▴▴▪▪▪▪ ", + "▴▴▴▴▪▪▪▪ ", + "▴▴▴▴▪▪▪▪ ", + "▰▴▴▴▪▪▪▦ ", + " " + ) + ); }); it("30 degrees", () => { - imgSrc - .clone() - .rotate(30, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ▰▰ ", - " ▪▪▪▪ ", - " ▴▪▪▪▪▪ ", - "▴▴▴▴▪▪▪▪ ", - "▴▴▴▴▪▪▴▴▴ ", - "▴▴▴▴▪▴▴▴▴▴ ", - " ▴▴▪▪▴▴▴▴▦ ", - " ▪▪▪▪▪▴▴▴ ", - " ▪▪▪▪▪ ", - " ▪▪▪ ", - " ▦ ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(30, true).getJGDSync(), + mkJGD( + " ▰▰ ", + " ▪▪▪▪ ", + " ▴▪▪▪▪▪ ", + "▴▴▴▴▪▪▪▪ ", + "▴▴▴▴▪▪▴▴▴ ", + "▴▴▴▴▪▴▴▴▴▴ ", + " ▴▴▪▪▴▴▴▴▦ ", + " ▪▪▪▪▪▴▴▴ ", + " ▪▪▪▪▪ ", + " ▪▪▪ ", + " ▦ ", + " " + ) + ); }); it("45 degrees", () => { - imgSrc - .clone() - .rotate(45, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▰ ", - " ▪▪▪ ", - " ▪▪▪▪▪ ", - " ▴▴▪▪▪▪▴ ", - " ▴▴▴▴▪▪▴▴▴ ", - "▰▰▴▴▴▴▴▴▴▴▦ ", - " ▴▴▴▴▪▪▴▴▴ ", - " ▴▴▪▪▪▪▴ ", - " ▪▪▪▪▪ ", - " ▪▪▪ ", - " ▦ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(45, true).getJGDSync(), + mkJGD( + " ", + " ▰ ", + " ▪▪▪ ", + " ▪▪▪▪▪ ", + " ▴▴▪▪▪▪▴ ", + " ▴▴▴▴▪▪▴▴▴ ", + "▰▰▴▴▴▴▴▴▴▴▦ ", + " ▴▴▴▴▪▪▴▴▴ ", + " ▴▴▪▪▪▪▴ ", + " ▪▪▪▪▪ ", + " ▪▪▪ ", + " ▦ ", + " ", + " " + ) + ); }); it("60 degrees", () => { - imgSrc - .clone() - .rotate(60, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ▰ ", - " ▪▪▪ ", - " ▪▪▪▪▪ ", - " ▪▪▪▪▪▴▴▴ ", - " ▴▴▪▪▴▴▴▴▦ ", - "▴▴▴▴▪▴▴▴▴▴ ", - "▴▴▴▴▪▪▴▴▴ ", - "▴▴▴▴▪▪▪▪ ", - " ▴▪▪▪▪▪ ", - " ▪▪▪▪ ", - " ▦▦ ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(60, true).getJGDSync(), + mkJGD( + " ▰ ", + " ▪▪▪ ", + " ▪▪▪▪▪ ", + " ▪▪▪▪▪▴▴▴ ", + " ▴▴▪▪▴▴▴▴▦ ", + "▴▴▴▴▪▴▴▴▴▴ ", + "▴▴▴▴▪▪▴▴▴ ", + "▴▴▴▴▪▪▪▪ ", + " ▴▪▪▪▪▪ ", + " ▪▪▪▪ ", + " ▦▦ ", + " " + ) + ); }); it("90 degrees", () => { - imgSrc - .clone() - .rotate(90, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - "▰▪▪▪▴▴▴▦ ", - "▪▪▪▪▴▴▴▴ ", - "▪▪▪▪▴▴▴▴ ", - "▪▪▪▪▴▴▴▴ ", - "▴▴▴▴▪▪▪▪ ", - "▴▴▴▴▪▪▪▪ ", - "▴▴▴▴▪▪▪▪ ", - "▰▴▴▴▪▪▪▦ ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(90, true).getJGDSync(), + mkJGD( + " ", + "▰▪▪▪▴▴▴▦ ", + "▪▪▪▪▴▴▴▴ ", + "▪▪▪▪▴▴▴▴ ", + "▪▪▪▪▴▴▴▴ ", + "▴▴▴▴▪▪▪▪ ", + "▴▴▴▴▪▪▪▪ ", + "▴▴▴▴▪▪▪▪ ", + "▰▴▴▴▪▪▪▦ ", + " " + ) + ); }); it("120 degrees", () => { - imgSrc - .clone() - .rotate(120, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▴▦ ", - " ▴▴▴▴ ", - " ▪▪▴▴▴▴ ", - "▰▪▪▪▴▴▴▴▪ ", - "▰▪▪▪▪▴▴▪▪▪ ", - " ▪▪▪▪▪▪▪▪▪ ", - " ▪▪▴▴▴▪▪▪▪▦ ", - " ▴▴▴▴▴▪▪ ", - " ▴▴▴▴▪ ", - " ▴▴▴ ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(120, true).getJGDSync(), + mkJGD( + " ", + " ▴▦ ", + " ▴▴▴▴ ", + " ▪▪▴▴▴▴ ", + "▰▪▪▪▴▴▴▴▪ ", + "▰▪▪▪▪▴▴▪▪▪ ", + " ▪▪▪▪▪▪▪▪▪ ", + " ▪▪▴▴▴▪▪▪▪▦ ", + " ▴▴▴▴▴▪▪ ", + " ▴▴▴▴▪ ", + " ▴▴▴ ", + " " + ) + ); }); it("135 degrees", () => { - imgSrc - .clone() - .rotate(135, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ", - " ▦ ", - " ▴▴▴ ", - " ▴▴▴▴▴ ", - " ▪▪▴▴▴▪▪ ", - " ▪▪▪▪▴▪▪▪▪ ", - " ▰▪▪▪▪▴▪▪▪▪▦ ", - " ▪▪▪▴▴▴▪▪▪ ", - " ▪▴▴▴▴▴▪ ", - " ▴▴▴▴▴ ", - " ▴▰▴ ", - " ▰ ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(135, true).getJGDSync(), + mkJGD( + " ", + " ", + " ▦ ", + " ▴▴▴ ", + " ▴▴▴▴▴ ", + " ▪▪▴▴▴▪▪ ", + " ▪▪▪▪▴▪▪▪▪ ", + " ▰▪▪▪▪▴▪▪▪▪▦ ", + " ▪▪▪▴▴▴▪▪▪ ", + " ▪▴▴▴▴▴▪ ", + " ▴▴▴▴▴ ", + " ▴▰▴ ", + " ▰ ", + " " + ) + ); }); it("180 degrees", () => { - imgSrc - .clone() - .rotate(180, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▦▴▴▴▪▪▪▦ ", - " ▴▴▴▴▪▪▪▪ ", - " ▴▴▴▴▪▪▪▪ ", - " ▴▴▴▴▪▪▪▪ ", - " ▪▪▪▪▴▴▴▴ ", - " ▪▪▪▪▴▴▴▴ ", - " ▪▪▪▪▴▴▴▴ ", - " ▰▪▪▪▴▴▴▰ ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(180, true).getJGDSync(), + mkJGD( + " ", + " ▦▴▴▴▪▪▪▦ ", + " ▴▴▴▴▪▪▪▪ ", + " ▴▴▴▴▪▪▪▪ ", + " ▴▴▴▴▪▪▪▪ ", + " ▪▪▪▪▴▴▴▴ ", + " ▪▪▪▪▴▴▴▴ ", + " ▪▪▪▪▴▴▴▴ ", + " ▰▪▪▪▴▴▴▰ ", + " " + ) + ); }); it("225 degrees", () => { - imgSrc - .clone() - .rotate(225, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▦ ", - " ▪▪▪ ", - " ▪▪▪▪▪ ", - " ▴▪▪▪▪▴▴ ", - " ▴▴▴▪▪▴▴▴▴ ", - " ▦▴▴▴▴▴▴▴▴▰▰ ", - " ▴▴▴▪▪▴▴▴▴ ", - " ▴▪▪▪▪▴▴ ", - " ▪▪▪▪▪ ", - " ▪▪▪ ", - " ▰ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(225, true).getJGDSync(), + mkJGD( + " ", + " ▦ ", + " ▪▪▪ ", + " ▪▪▪▪▪ ", + " ▴▪▪▪▪▴▴ ", + " ▴▴▴▪▪▴▴▴▴ ", + " ▦▴▴▴▴▴▴▴▴▰▰ ", + " ▴▴▴▪▪▴▴▴▴ ", + " ▴▪▪▪▪▴▴ ", + " ▪▪▪▪▪ ", + " ▪▪▪ ", + " ▰ ", + " ", + " " + ) + ); }); it("270 degrees", () => { - imgSrc - .clone() - .rotate(270, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ▦▪▪▪▴▴▴▰ ", - " ▪▪▪▪▴▴▴▴ ", - " ▪▪▪▪▴▴▴▴ ", - " ▪▪▪▪▴▴▴▴ ", - " ▴▴▴▴▪▪▪▪ ", - " ▴▴▴▴▪▪▪▪ ", - " ▴▴▴▴▪▪▪▪ ", - " ▦▴▴▴▪▪▪▰ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(270, true).getJGDSync(), + mkJGD( + " ▦▪▪▪▴▴▴▰ ", + " ▪▪▪▪▴▴▴▴ ", + " ▪▪▪▪▴▴▴▴ ", + " ▪▪▪▪▴▴▴▴ ", + " ▴▴▴▴▪▪▪▪ ", + " ▴▴▴▴▪▪▪▪ ", + " ▴▴▴▴▪▪▪▪ ", + " ▦▴▴▴▪▪▪▰ ", + " ", + " " + ) + ); }); it("315 degrees", () => { - imgSrc - .clone() - .rotate(315, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ▰ ", - " ▴▰▴ ", - " ▴▴▴▴▴ ", - " ▪▴▴▴▴▴▪ ", - " ▪▪▪▴▴▴▪▪▪ ", - " ▦▪▪▪▪▴▪▪▪▪▰ ", - " ▪▪▪▪▴▪▪▪▪ ", - " ▪▪▴▴▴▪▪ ", - " ▴▴▴▴▴ ", - " ▴▴▴ ", - " ▦ ", - " ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(315, true).getJGDSync(), + mkJGD( + " ▰ ", + " ▴▰▴ ", + " ▴▴▴▴▴ ", + " ▪▴▴▴▴▴▪ ", + " ▪▪▪▴▴▴▪▪▪ ", + " ▦▪▪▪▪▴▪▪▪▪▰ ", + " ▪▪▪▪▴▪▪▪▪ ", + " ▪▪▴▴▴▪▪ ", + " ▴▴▴▴▴ ", + " ▴▴▴ ", + " ▦ ", + " ", + " ", + " " + ) + ); }); it("360 degrees", () => { - imgSrc - .clone() - .rotate(360, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "▰▴▴▴▪▪▪▰ ", - "▴▴▴▴▪▪▪▪ ", - "▴▴▴▴▪▪▪▪ ", - "▴▴▴▴▪▪▪▪ ", - "▪▪▪▪▴▴▴▴ ", - "▪▪▪▪▴▴▴▴ ", - "▪▪▪▪▴▴▴▴ ", - "▦▪▪▪▴▴▴▦ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(360, true).getJGDSync(), + mkJGD( + "▰▴▴▴▪▪▪▰ ", + "▴▴▴▴▪▪▪▪ ", + "▴▴▴▴▪▪▪▪ ", + "▴▴▴▴▪▪▪▪ ", + "▪▪▪▪▴▴▴▴ ", + "▪▪▪▪▴▴▴▴ ", + "▪▪▪▪▴▴▴▴ ", + "▦▪▪▪▴▴▴▦ ", + " ", + " " + ) + ); }); }); @@ -351,95 +313,83 @@ describe("Rotate a image with odd size", () => { }); it("45 degrees", () => { - imgSrc - .clone() - .rotate(45, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▪ ", - " ▪▪▪ ", - " ▦▪▪▪▦ ", - " ▴▴▦▪▦▴▴ ", - " ▴▴▴▴▦▴▴▴▴ ", - " ▴▴▦▴▦▴▴ ", - " ▦▴▴▴▦ ", - " ▴▴▴ ", - " ▴ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(45, true).getJGDSync(), + mkJGD( + " ", + " ▪ ", + " ▪▪▪ ", + " ▦▪▪▪▦ ", + " ▴▴▦▪▦▴▴ ", + " ▴▴▴▴▦▴▴▴▴ ", + " ▴▴▦▴▦▴▴ ", + " ▦▴▴▴▦ ", + " ▴▴▴ ", + " ▴ ", + " ", + " " + ) + ); }); it("135 degrees", () => { - imgSrc - .clone() - .rotate(135, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▴ ", - " ▴▴▴ ", - " ▦▴▴▴▦ ", - " ▪▪▦▴▦▴▴ ", - " ▪▪▪▪▦▴▴▴▴ ", - " ▪▪▦▴▦▴▴ ", - " ▦▴▴▴▦ ", - " ▴▴▴ ", - " ▴ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(135, true).getJGDSync(), + mkJGD( + " ", + " ▴ ", + " ▴▴▴ ", + " ▦▴▴▴▦ ", + " ▪▪▦▴▦▴▴ ", + " ▪▪▪▪▦▴▴▴▴ ", + " ▪▪▦▴▦▴▴ ", + " ▦▴▴▴▦ ", + " ▴▴▴ ", + " ▴ ", + " ", + " " + ) + ); }); it("225 degrees", () => { - imgSrc - .clone() - .rotate(225, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▴ ", - " ▴▴▴ ", - " ▦▴▴▴▦ ", - " ▴▴▦▴▦▴▴ ", - " ▴▴▴▴▦▴▴▴▴ ", - " ▴▴▦▪▦▴▴ ", - " ▦▪▪▪▦ ", - " ▪▪▪ ", - " ▪ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(225, true).getJGDSync(), + mkJGD( + " ", + " ▴ ", + " ▴▴▴ ", + " ▦▴▴▴▦ ", + " ▴▴▦▴▦▴▴ ", + " ▴▴▴▴▦▴▴▴▴ ", + " ▴▴▦▪▦▴▴ ", + " ▦▪▪▪▦ ", + " ▪▪▪ ", + " ▪ ", + " ", + " " + ) + ); }); it("315 degrees", () => { - imgSrc - .clone() - .rotate(315, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▴ ", - " ▴▴▴ ", - " ▦▴▴▴▦ ", - " ▴▴▦▴▦▪▪ ", - " ▴▴▴▴▦▪▪▪▪ ", - " ▴▴▦▴▦▪▪ ", - " ▦▴▴▴▦ ", - " ▴▴▴ ", - " ▴ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(315, true).getJGDSync(), + mkJGD( + " ", + " ▴ ", + " ▴▴▴ ", + " ▦▴▴▴▦ ", + " ▴▴▦▴▦▪▪ ", + " ▴▴▴▴▦▪▪▪▪ ", + " ▴▴▦▴▦▪▪ ", + " ▦▴▴▴▦ ", + " ▴▴▴ ", + " ▴ ", + " ", + " " + ) + ); }); }); @@ -456,181 +406,154 @@ describe("Rotate a non-square image", () => { }); it("1 degrees", () => { - imgSrc - .clone() - .rotate(1, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - "▴▴▴▴▪▪▪▪ ", - "▴▴▴▴▪▪▪▪ ", - "▦▦▦▦▴▴▴▴ ", - "▦▦▦▦▴▴▴▴ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(1, true).getJGDSync(), + mkJGD( + "▴▴▴▴▪▪▪▪ ", + "▴▴▴▴▪▪▪▪ ", + "▦▦▦▦▴▴▴▴ ", + "▦▦▦▦▴▴▴▴ ", + " ", + " " + ) + ); }); it("10 degrees", () => { - imgSrc - .clone() - .rotate(10, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ▪ ", - " ▴▴▴▪▪▪▪ ", - "▴▴▴▴▪▪▪▴ ", - "▴▴▦▦▴▴▴▴ ", - "▦▦▦▦▴▴▴ ", - "▦▦ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(10, true).getJGDSync(), + mkJGD( + " ▪ ", + " ▴▴▴▪▪▪▪ ", + "▴▴▴▴▪▪▪▴ ", + "▴▴▦▦▴▴▴▴ ", + "▦▦▦▦▴▴▴ ", + "▦▦ ", + " ", + " " + ) + ); }); it("30 degrees", () => { - imgSrc - .clone() - .rotate(30, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▪▪ ", - " ▪▪▪▪ ", - " ▴▴▪▪▴▴▴ ", - "▴▴▴▦▴▴▴ ", - "▴▴▦▦▴▴ ", - "▦▦▦▦ ", - " ▦ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(30, true).getJGDSync(), + mkJGD( + " ", + " ▪▪ ", + " ▪▪▪▪ ", + " ▴▴▪▪▴▴▴ ", + "▴▴▴▦▴▴▴ ", + "▴▴▦▦▴▴ ", + "▦▦▦▦ ", + " ▦ ", + " ", + " " + ) + ); }); it("45 degrees", () => { - imgSrc - .clone() - .rotate(45, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▪▪ ", - " ▪▪▪▴ ", - " ▴▪▪▴▴▴ ", - " ▴▴▴▴▴▴ ", - "▴▴▴▦▦▴ ", - "▴▴▦▦▦ ", - " ▦▦▦ ", - " ▦ ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(45, true).getJGDSync(), + mkJGD( + " ", + " ▪▪ ", + " ▪▪▪▴ ", + " ▴▪▪▴▴▴ ", + " ▴▴▴▴▴▴ ", + "▴▴▴▦▦▴ ", + "▴▴▦▦▦ ", + " ▦▦▦ ", + " ▦ ", + " " + ) + ); }); it("90 degrees", () => { - imgSrc - .clone() - .rotate(90, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - "▪▪▴▴ ", - "▪▪▴▴ ", - "▪▪▴▴ ", - "▪▪▴▴ ", - "▴▴▦▦ ", - "▴▴▦▦ ", - "▴▴▦▦ ", - "▴▴▦▦ ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(90, true).getJGDSync(), + mkJGD( + " ", + "▪▪▴▴ ", + "▪▪▴▴ ", + "▪▪▴▴ ", + "▪▪▴▴ ", + "▴▴▦▦ ", + "▴▴▦▦ ", + "▴▴▦▦ ", + "▴▴▦▦ ", + " " + ) + ); }); it("135 degrees", () => { - imgSrc - .clone() - .rotate(135, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▴ ", - " ▴▴▴ ", - " ▪▪▴▴▴ ", - " ▪▪▪▴▦▦ ", - " ▪▪▴▦▦▦ ", - " ▴▴▴▦▦▦ ", - " ▴▴▴▦ ", - " ▴▴ ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(135, true).getJGDSync(), + mkJGD( + " ", + " ▴ ", + " ▴▴▴ ", + " ▪▪▴▴▴ ", + " ▪▪▪▴▦▦ ", + " ▪▪▴▦▦▦ ", + " ▴▴▴▦▦▦ ", + " ▴▴▴▦ ", + " ▴▴ ", + " " + ) + ); }); it("180 degrees", () => { - imgSrc - .clone() - .rotate(180, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ", - " ▴▴▴▴▦▦▦▦ ", - " ▴▴▴▴▦▦▦▦ ", - " ▪▪▪▪▴▴▴▴ ", - " ▪▪▪▪▴▴▴▴ ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(180, true).getJGDSync(), + mkJGD( + " ", + " ▴▴▴▴▦▦▦▦ ", + " ▴▴▴▴▦▦▦▦ ", + " ▪▪▪▪▴▴▴▴ ", + " ▪▪▪▪▴▴▴▴ ", + " " + ) + ); }); it("225 degrees", () => { - imgSrc - .clone() - .rotate(225, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ▦ ", - " ▦▦▦ ", - " ▦▦▦▴▴ ", - " ▴▦▦▴▴▴ ", - " ▴▴▴▴▴▴ ", - " ▴▴▴▪▪▴ ", - " ▴▪▪▪ ", - " ▪▪ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(225, true).getJGDSync(), + mkJGD( + " ▦ ", + " ▦▦▦ ", + " ▦▦▦▴▴ ", + " ▴▦▦▴▴▴ ", + " ▴▴▴▴▴▴ ", + " ▴▴▴▪▪▴ ", + " ▴▪▪▪ ", + " ▪▪ ", + " ", + " " + ) + ); }); it("315 degrees", () => { - imgSrc - .clone() - .rotate(315, true) - .getJGDSync() - .should.be.sameJGD( - mkJGD( - " ▴▴ ", - " ▦▴▴▴ ", - "▦▦▦▴▴▴ ", - " ▦▦▦▴▪▪ ", - " ▦▦▴▪▪▪ ", - " ▴▴▴▪▪ ", - " ▴▴▴ ", - " ▴ ", - " ", - " " - ) - ); + expectToBeJGD( + imgSrc.clone().rotate(315, true).getJGDSync(), + mkJGD( + " ▴▴ ", + " ▦▴▴▴ ", + "▦▦▦▴▴▴ ", + " ▦▦▦▴▪▪ ", + " ▦▦▴▪▪▪ ", + " ▴▴▴▪▪ ", + " ▴▴▴ ", + " ▴ ", + " ", + " " + ) + ); }); }); diff --git a/packages/plugin-shadow/test/shadow.test.js b/packages/plugin-shadow/test/shadow.test.js index 7f2e4dc9d..2ee56166b 100644 --- a/packages/plugin-shadow/test/shadow.test.js +++ b/packages/plugin-shadow/test/shadow.test.js @@ -2,6 +2,7 @@ import { Jimp, mkJGD, getTestDir } from "@jimp/test-utils"; import configure from "@jimp/custom"; import resize from "@jimp/plugin-resize"; import blur from "@jimp/plugin-blur"; +import expect from "@storybook/expect"; import shadow from "../src"; @@ -24,8 +25,8 @@ describe("Shadow", () => { ) ); - testImage - .shadow({ x: -1, y: 1, blur: 1 }) - .bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + expect(testImage.shadow({ x: -1, y: 1, blur: 1 }).bitmap.data).toEqual( + expectedImg.bitmap.data + ); }); }); diff --git a/packages/plugin-threshold/test/threshold.test.js b/packages/plugin-threshold/test/threshold.test.js index 325f83136..709da3e1d 100644 --- a/packages/plugin-threshold/test/threshold.test.js +++ b/packages/plugin-threshold/test/threshold.test.js @@ -3,6 +3,7 @@ import configure from "@jimp/custom"; import jpeg from "@jimp/jpeg"; import color from "@jimp/plugin-color"; import resize from "@jimp/plugin-resize"; +import expect from "@storybook/expect"; import threshold from "../src"; @@ -22,9 +23,8 @@ describe("Threshold", function () { getTestDir(__dirname) + "/images/hands.jpg" ); - testImage - .threshold({ max: 200, replace: 255 }) - .hash() - .should.be.equal(expectedImage.hash()); + expect(testImage.threshold({ max: 200, replace: 255 }).hash()).toBe( + expectedImage.hash() + ); }); }); diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index 6da029bd4..b1ec3dc63 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -26,7 +26,6 @@ "pngjs": "^6.0.0" }, "devDependencies": { - "@jimp/custom": "link:../custom", - "should": "^13.2.3" + "@jimp/custom": "link:../custom" } } diff --git a/packages/test-utils/src/index.js b/packages/test-utils/src/index.js index 65b869baf..b48e40ee3 100644 --- a/packages/test-utils/src/index.js +++ b/packages/test-utils/src/index.js @@ -1,9 +1,8 @@ -import should from "should"; +import expect from "@storybook/expect"; +import equal from "fast-deep-equal"; export const Jimp = require("./jgd-wrapper"); -const shouldAssertion = {}.should.be.constructor.prototype; - export function hasOwnProp(obj, key) { return Object.prototype.hasOwnProperty.call(obj, key); } @@ -75,25 +74,57 @@ export function jgdReadableMatrix(img) { return rMatrix.join("\n"); } -shouldAssertion.sameJGD = function (targetJGD, message) { - message = message ? " " + message : ""; - const testJGD = this.obj; - should.exist(testJGD.width, "Width was not defined." + message); - should.exist(testJGD.height, "Height was not defined." + message); - testJGD.width.should.be.equal( - targetJGD.width, - "Width is not the expected." + message - ); - testJGD.height.should.be.equal( - targetJGD.height, - "Height is not the expected." + message - ); - const matrixMsg = message || "The pixel matrix is not the expected."; - jgdReadableMatrix(testJGD).should.be.equal( - jgdReadableMatrix(targetJGD), - matrixMsg - ); -}; +function determineJGDError(testJGD, targetJGD) { + if (typeof testJGD.width === "undefined") { + return { + pass: false, + message: `Expected testJGD.width to be defined`, + }; + } + + if (typeof testJGD.height === "undefined") { + return { + pass: false, + message: `Expected testJGD.height to be defined`, + }; + } + + if (testJGD.width !== targetJGD.width) { + return { + pass: false, + message: `Expected testJGD.width to be ${targetJGD.width} but got ${testJGD.width}`, + }; + } + + if (testJGD.height !== targetJGD.height) { + console.log(typeof testJGD.height, typeof targetJGD.height); + return { + pass: false, + message: `Expected testJGD.height to be ${targetJGD.height} but got ${testJGD.height}`, + }; + } + + if (!equal(jgdReadableMatrix(testJGD), jgdReadableMatrix(targetJGD))) { + return { + pass: false, + message: "Expected testJGD to be equal to targetJGD", + }; + } + + return { + pass: true, + }; +} + +export function expectToBeJGD(testJGD, targetJGD) { + const error = determineJGDError(testJGD, targetJGD); + + if (error.pass) { + return; + } + + throw new Error(error.message); +} export function donutJGD(_, i, X) { /* eslint comma-spacing: off */ diff --git a/packages/test-utils/test/jgd.test.js b/packages/test-utils/test/jgd.test.js index 6bb54c6ad..022d03d60 100644 --- a/packages/test-utils/test/jgd.test.js +++ b/packages/test-utils/test/jgd.test.js @@ -1,4 +1,5 @@ import { Jimp, donutJGD } from "../src"; +import expect from "@storybook/expect"; const donut = donutJGD( // RRGGBBAA @@ -20,20 +21,20 @@ describe("JGD - JS Graphic Description", () => { const image = await Jimp.read(donut); const buffer = await image.getBufferAsync("image/png"); - buffer.toString("base64").should.be.equal(donutPngBase64); + expect(buffer.toString("base64")).toBe(donutPngBase64); }); it("Jimp exports JGD sync", async () => { const image = await Jimp.read(donutPngBuffer); - image.getJGDSync().should.be.deepEqual(donut); + expect(image.getJGDSync()).toEqual(donut); }); it("Jimp exports JGD async", async () => { const image = await Jimp.read(donutPngBuffer); const jgd = await image.getJGD(); - jgd.data.length.should.be.equal(donut.data.length); - jgd.should.be.deepEqual(donut); + expect(jgd.data.length).toBe(donut.data.length); + expect(jgd).toEqual(donut); }); }); diff --git a/packages/type-bmp/test/bmp.test.js b/packages/type-bmp/test/bmp.test.js index c72536eed..09587cec3 100644 --- a/packages/type-bmp/test/bmp.test.js +++ b/packages/type-bmp/test/bmp.test.js @@ -1,7 +1,6 @@ -/* eslint-disable no-control-regex */ - import { Jimp, getTestDir } from "@jimp/test-utils"; import configure from "@jimp/custom"; +import expect from "@storybook/expect"; import bmp from "../src"; @@ -13,9 +12,9 @@ describe("BMP", () => { it("load BMP", async () => { const image = await jimp.read(imagesDir + "/windows95.bmp"); - image.getPixelColor(10, 10).should.be.equal(0xeff7f7ff); - image.getPixelColor(150, 80).should.be.equal(0x73add6ff); - image.getPixelColor(190, 200).should.be.equal(0xf7c300ff); + expect(image.getPixelColor(10, 10)).toBe(0xeff7f7ff); + expect(image.getPixelColor(150, 80)).toBe(0x73add6ff); + expect(image.getPixelColor(190, 200)).toBe(0xf7c300ff); }); it("export BMP", async () => { @@ -29,7 +28,7 @@ describe("BMP", () => { }); const buffer = await image.getBufferAsync("image/bmp"); - buffer.toString().should.match(/^BMZ\u0000/); + expect(buffer.toString()).toMatch(/^BMZ\u0000/); }); it("uses correct colors for BMP", async function () { @@ -42,6 +41,6 @@ describe("BMP", () => { getTestDir(__dirname) + "/images/windows95.bmp" ); - image.bitmap.data.should.be.deepEqual(expectedImg.bitmap.data); + expect(image.bitmap.data).toEqual(expectedImg.bitmap.data); }); }); diff --git a/packages/type-gif/test/gif.test.js b/packages/type-gif/test/gif.test.js index 7b316887e..664fa676f 100644 --- a/packages/type-gif/test/gif.test.js +++ b/packages/type-gif/test/gif.test.js @@ -1,5 +1,6 @@ import { Jimp, getTestDir } from "@jimp/test-utils"; import configure from "@jimp/custom"; +import expect from "@storybook/expect"; import gif from "../src"; @@ -10,17 +11,17 @@ describe("GIF", () => { it("load GIF", async () => { const image = await jimp.read(imagesDir + "/flower.gif"); - image.getPixelColor(10, 10).should.be.equal(0xe5e6d9ff); + expect(image.getPixelColor(10, 10)).toBe(0xe5e6d9ff); }); it("load animated GIF", async () => { const image = await jimp.read(imagesDir + "/animated.gif"); - image.getPixelColor(10, 10).should.be.equal(0xa1d2f1ff); + expect(image.getPixelColor(10, 10)).toBe(0xa1d2f1ff); }); it("export GIF", async () => { const jgd = await jimp.read(imagesDir + "/flower.gif"); const buffer = await jgd.getBufferAsync("image/gif"); - buffer.toString().startsWith("GIF").should.be.equal(true); + expect(buffer.toString()).toMatch(/^GIF/); }); }); diff --git a/packages/type-jpeg/test/jpeg.test.js b/packages/type-jpeg/test/jpeg.test.js index 6ee30b7cb..5abf22d88 100644 --- a/packages/type-jpeg/test/jpeg.test.js +++ b/packages/type-jpeg/test/jpeg.test.js @@ -1,5 +1,6 @@ import { Jimp, getTestDir } from "@jimp/test-utils"; import configure from "@jimp/custom"; +import expect from "@storybook/expect"; import jpeg from "../src"; @@ -11,17 +12,17 @@ describe("JPEG", () => { it("load JPG", async () => { const image = await jimp.read(imagesDir + "/cops.jpg"); - image.getPixelColor(10, 10).should.be.equal(0x3f4a02ff); - image.getPixelColor(220, 190).should.be.equal(0x5d94b6ff); - image.getPixelColor(350, 130).should.be.equal(0xdf7944ff); + expect(image.getPixelColor(10, 10)).toBe(0x3f4a02ff); + expect(image.getPixelColor(220, 190)).toBe(0x5d94b6ff); + expect(image.getPixelColor(350, 130)).toBe(0xdf7944ff); }); it("load JPG with fill bytes", async () => { const image = await jimp.read(imagesDir + "/fillbytes.jpg"); - image.getPixelColor(10, 10).should.be.equal(0xaeb8c3ff); - image.getPixelColor(220, 190).should.be.equal(0x262b21ff); - image.getPixelColor(350, 130).should.be.equal(0x4e5d30ff); + expect(image.getPixelColor(10, 10)).toBe(0xaeb8c3ff); + expect(image.getPixelColor(220, 190)).toBe(0x262b21ff); + expect(image.getPixelColor(350, 130)).toBe(0x4e5d30ff); }); it("export JPG", async () => { @@ -36,6 +37,6 @@ describe("JPEG", () => { image.quality(50); const buffer = await image.getBufferAsync("image/jpeg"); - buffer.toString().should.match(/^.{3,9}JFIF\u0000/); + expect(buffer.toString()).toMatch(/^.{3,9}JFIF\u0000/); }); }); diff --git a/packages/type-png/test/png.test.js b/packages/type-png/test/png.test.js index cad4a49b3..ff10457c6 100644 --- a/packages/type-png/test/png.test.js +++ b/packages/type-png/test/png.test.js @@ -1,5 +1,6 @@ import { Jimp, getTestDir } from "@jimp/test-utils"; import configure from "@jimp/custom"; +import expect from "@storybook/expect"; import png from "../src"; @@ -11,9 +12,9 @@ describe("PNG", () => { it("load PNG", async () => { const image = await jimp.read(imagesDir + "/dice.png"); - image.getPixelColor(10, 10).should.be.equal(0x00000000); - image.getPixelColor(160, 80).should.be.equal(0x1c1cd4ff); - image.getPixelColor(400, 250).should.be.equal(0x7e0c0cda); + expect(image.getPixelColor(10, 10)).toBe(0x00000000); + expect(image.getPixelColor(160, 80)).toBe(0x1c1cd4ff); + expect(image.getPixelColor(400, 250)).toBe(0x7e0c0cda); }); it("export PNG", async () => { @@ -27,7 +28,7 @@ describe("PNG", () => { }); const buffer = await jgd.getBufferAsync("image/png"); - buffer.toString().should.match(/^.PNG\r\n/); + expect(buffer.toString()).toMatch(/^.PNG\r\n/); }); it("should use png options", async () => { @@ -55,6 +56,6 @@ describe("PNG", () => { .colorType(0) .getBufferAsync(Jimp.MIME_PNG); - image.should.be.deepEqual(expectedBuffer); + expect(image).toEqual(expectedBuffer); }); }); diff --git a/packages/type-tiff/test/tiff.test.js b/packages/type-tiff/test/tiff.test.js index 05211f28f..be1e98f0b 100644 --- a/packages/type-tiff/test/tiff.test.js +++ b/packages/type-tiff/test/tiff.test.js @@ -1,5 +1,6 @@ import { Jimp, getTestDir } from "@jimp/test-utils"; import configure from "@jimp/custom"; +import expect from "@storybook/expect"; import tiff from "../src"; @@ -11,9 +12,9 @@ describe("TIFF", () => { it("load TIFF", async () => { const image = await jimp.read(imagesDir + "/rgb.tiff"); - image.getPixelColor(10, 10).should.be.equal(0xa4988bff); - image.getPixelColor(220, 190).should.be.equal(0xe0d7ddff); - image.getPixelColor(350, 130).should.be.equal(0x565433ff); + expect(image.getPixelColor(10, 10)).toBe(0xa4988bff); + expect(image.getPixelColor(220, 190)).toBe(0xe0d7ddff); + expect(image.getPixelColor(350, 130)).toBe(0x565433ff); }); const simpleJGD = { @@ -29,6 +30,6 @@ describe("TIFF", () => { const image = await jimp.read(simpleJGD); const buffer = await image.getBufferAsync("image/tiff"); - buffer.toString().should.match(/^MM\u0000*\u0000/); + expect(buffer.toString()).toMatch(/^MM\u0000*\u0000/); }); }); diff --git a/yarn.lock b/yarn.lock index e103728b3..ee240e1e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -187,7 +187,7 @@ dependencies: "@babel/highlight" "^7.0.0" -"@babel/code-frame@^7.18.6": +"@babel/code-frame@^7.12.13", "@babel/code-frame@^7.18.6": version "7.18.6" resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a" integrity sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q== @@ -266,7 +266,7 @@ lru-cache "^5.1.1" semver "^6.3.0" -"@babel/helper-create-class-features-plugin@^7.18.6", "@babel/helper-create-class-features-plugin@^7.20.5", "@babel/helper-create-class-features-plugin@^7.20.7": +"@babel/helper-create-class-features-plugin@^7.18.6", "@babel/helper-create-class-features-plugin@^7.20.12", "@babel/helper-create-class-features-plugin@^7.20.5", "@babel/helper-create-class-features-plugin@^7.20.7": version "7.20.12" resolved "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.20.12.tgz#4349b928e79be05ed2d1643b20b99bb87c503819" integrity sha512-9OunRkbT0JQcednL0UFvbfXpAsUXiGjUk0a7sN8fUXX7Mue79cUSMjHGDRRi/Vz9vYlpIhLV5fMD5dKoMhhsNQ== @@ -750,6 +750,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.14.5" +"@babel/plugin-syntax-typescript@^7.20.0": + version "7.20.0" + resolved "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.20.0.tgz#4e9a0cfc769c85689b77a2e642d24e9f697fc8c7" + integrity sha512-rd9TkG+u1CExzS4SM1BlMEhMXwFLKVjOAFFCDx9PbX5ycJWDoWMcwdJH9RhkPu1dOgn5TrxLot/Gx6lWFuAUNQ== + dependencies: + "@babel/helper-plugin-utils" "^7.19.0" + "@babel/plugin-transform-arrow-functions@^7.18.6": version "7.20.7" resolved "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.20.7.tgz#bea332b0e8b2dab3dafe55a163d8227531ab0551" @@ -950,18 +957,6 @@ dependencies: "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-runtime@^7.19.6": - version "7.19.6" - resolved "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.19.6.tgz#9d2a9dbf4e12644d6f46e5e75bfbf02b5d6e9194" - integrity sha512-PRH37lz4JU156lYFW1p8OxE5i7d6Sl/zV58ooyr+q1J1lnQPyg5tIiXlIwNVhJaY4W3TmOtdc8jqdXQcB1v5Yw== - dependencies: - "@babel/helper-module-imports" "^7.18.6" - "@babel/helper-plugin-utils" "^7.19.0" - babel-plugin-polyfill-corejs2 "^0.3.3" - babel-plugin-polyfill-corejs3 "^0.6.0" - babel-plugin-polyfill-regenerator "^0.4.1" - semver "^6.3.0" - "@babel/plugin-transform-shorthand-properties@^7.18.6": version "7.18.6" resolved "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.18.6.tgz#6d6df7983d67b195289be24909e3f12a8f664dc9" @@ -998,6 +993,15 @@ dependencies: "@babel/helper-plugin-utils" "^7.18.9" +"@babel/plugin-transform-typescript@^7.18.6": + version "7.20.13" + resolved "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.20.13.tgz#e3581b356b8694f6ff450211fe6774eaff8d25ab" + integrity sha512-O7I/THxarGcDZxkgWKMUrk7NK1/WbHAg3Xx86gqS6x9MTrNL6AwIluuZ96ms4xeDe6AVx6rjHbWHP7x26EPQBA== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.20.12" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/plugin-syntax-typescript" "^7.20.0" + "@babel/plugin-transform-unicode-escapes@^7.18.10": version "7.18.10" resolved "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz#1ecfb0eda83d09bbcb77c09970c2dd55832aa246" @@ -1105,6 +1109,15 @@ "@babel/types" "^7.4.4" esutils "^2.0.2" +"@babel/preset-typescript@^7.18.6": + version "7.18.6" + resolved "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.18.6.tgz#ce64be3e63eddc44240c6358daefac17b3186399" + integrity sha512-s9ik86kXBAnD760aybBucdpnLsAt0jK1xqJn2juOn9lkOvSHV60os5hxoVJsPzMQxvnUJFAlkont2DvvaYEBtQ== + dependencies: + "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-validator-option" "^7.18.6" + "@babel/plugin-transform-typescript" "^7.18.6" + "@babel/register@^7.18.9": version "7.18.9" resolved "https://registry.npmjs.org/@babel/register/-/register-7.18.9.tgz#1888b24bc28d5cc41c412feb015e9ff6b96e439c" @@ -1348,14 +1361,40 @@ resolved "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== +"@jest/expect-utils@^29.4.1": + version "29.4.1" + resolved "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.4.1.tgz#105b9f3e2c48101f09cae2f0a4d79a1b3a419cbb" + integrity sha512-w6YJMn5DlzmxjO00i9wu2YSozUYRBhIoJ6nQwpMYcBMtiqMGJm1QBzOf6DDgRao8dbtpDoaqLg6iiQTvv0UHhQ== + dependencies: + jest-get-type "^29.2.0" + +"@jest/schemas@^29.4.0": + version "29.4.0" + resolved "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.0.tgz#0d6ad358f295cc1deca0b643e6b4c86ebd539f17" + integrity sha512-0E01f/gOZeNTG76i5eWWSupvSHaIINrTie7vCyjiYFKgzNdyEGd12BUv4oNBFHOqlHDbtoJi3HrQ38KCC90NsQ== + dependencies: + "@sinclair/typebox" "^0.25.16" + +"@jest/types@^29.4.1": + version "29.4.1" + resolved "https://registry.npmjs.org/@jest/types/-/types-29.4.1.tgz#f9f83d0916f50696661da72766132729dcb82ecb" + integrity sha512-zbrAXDUOnpJ+FMST2rV7QZOgec8rskg2zv8g2ajeqitp4tvZiyqTCYXANrKsM+ryj5o+LI+ZN2EgU9drrkiwSA== + dependencies: + "@jest/schemas" "^29.4.0" + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^3.0.0" + "@types/node" "*" + "@types/yargs" "^17.0.8" + chalk "^4.0.0" + "@jimp/bmp@link:packages/type-bmp": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" bmp-js "^0.1.0" "@jimp/core@link:packages/core": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" any-base "^1.1.0" @@ -1368,132 +1407,132 @@ tinycolor2 "^1.4.1" "@jimp/custom@link:packages/custom": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/core" "link:packages/core" "@jimp/gif@link:packages/type-gif": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" gifwrap "^0.9.2" omggif "^1.0.9" "@jimp/jpeg@link:packages/type-jpeg": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" jpeg-js "^0.4.4" "@jimp/plugin-blit@link:packages/plugin-blit": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-blur@link:packages/plugin-blur": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-circle@link:packages/plugin-circle": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-color@link:packages/plugin-color": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" tinycolor2 "^1.4.1" "@jimp/plugin-contain@link:packages/plugin-contain": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-cover@link:packages/plugin-cover": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-crop@link:packages/plugin-crop": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-displace@link:packages/plugin-displace": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-dither@link:packages/plugin-dither": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-fisheye@link:packages/plugin-fisheye": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-flip@link:packages/plugin-flip": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-gaussian@link:packages/plugin-gaussian": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-invert@link:packages/plugin-invert": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-mask@link:packages/plugin-mask": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-normalize@link:packages/plugin-normalize": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-print@link:packages/plugin-print": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" load-bmfont "^1.4.1" "@jimp/plugin-resize@link:packages/plugin-resize": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-rotate@link:packages/plugin-rotate": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-scale@link:packages/plugin-scale": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-shadow@link:packages/plugin-shadow": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugin-threshold@link:packages/plugin-threshold": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" "@jimp/plugins@link:packages/plugins": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/plugin-blit" "link:packages/plugin-blit" "@jimp/plugin-blur" "link:packages/plugin-blur" @@ -1519,23 +1558,23 @@ timm "^1.6.1" "@jimp/png@link:packages/type-png": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/utils" "link:packages/utils" pngjs "^6.0.0" "@jimp/test-utils@link:packages/test-utils": - version "0.20.0" + version "0.21.3" dependencies: pngjs "^6.0.0" "@jimp/tiff@link:packages/type-tiff": - version "0.20.0" + version "0.21.3" dependencies: utif2 "^4.0.1" "@jimp/types@link:packages/types": - version "0.20.0" + version "0.21.3" dependencies: "@jimp/bmp" "link:packages/type-bmp" "@jimp/gif" "link:packages/type-gif" @@ -1545,7 +1584,7 @@ timm "^1.6.1" "@jimp/utils@link:packages/utils": - version "0.20.0" + version "0.21.3" dependencies: regenerator-runtime "^0.13.3" @@ -2546,6 +2585,18 @@ dependencies: any-observable "^0.3.0" +"@sinclair/typebox@^0.25.16": + version "0.25.21" + resolved "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.21.tgz#763b05a4b472c93a8db29b2c3e359d55b29ce272" + integrity sha512-gFukHN4t8K4+wVC+ECqeqwzBDeFeTzBXroBTqE6vcWrQGbEUpHO7LYdG0f4xnvYq4VOEwITSlHlp0JBAIFMS/g== + +"@storybook/expect@^27.5.2-0": + version "27.5.2-0" + resolved "https://registry.npmjs.org/@storybook/expect/-/expect-27.5.2-0.tgz#131fc4336106805ccd100809a3c2852d31f1da68" + integrity sha512-cP99mhWN/JeCp7VSIiymvj5tmuMY050iFohvp8Zq+kewKsBSZ6/qpTJAGCCZk6pneTcp4S0Fm5BSqyxzbyJ3gw== + dependencies: + "@types/jest" ">=26.0.0" + "@tokenizer/token@^0.3.0": version "0.3.0" resolved "https://registry.yarnpkg.com/@tokenizer/token/-/token-0.3.0.tgz#fe98a93fe789247e998c75e74e9c7c63217aa276" @@ -2626,6 +2677,33 @@ "@types/minimatch" "*" "@types/node" "*" +"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0": + version "2.0.4" + resolved "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44" + integrity sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g== + +"@types/istanbul-lib-report@*": + version "3.0.0" + resolved "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#c14c24f18ea8190c118ee7562b7ff99a36552686" + integrity sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg== + dependencies: + "@types/istanbul-lib-coverage" "*" + +"@types/istanbul-reports@^3.0.0": + version "3.0.1" + resolved "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz#9153fe98bba2bd565a63add9436d6f0d7f8468ff" + integrity sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw== + dependencies: + "@types/istanbul-lib-report" "*" + +"@types/jest@>=26.0.0": + version "29.4.0" + resolved "https://registry.npmjs.org/@types/jest/-/jest-29.4.0.tgz#a8444ad1704493e84dbf07bb05990b275b3b9206" + integrity sha512-VaywcGQ9tPorCX/Jkkni7RWGFfI11whqzs8dvxF41P17Z+z872thvEvlIbznjPJ02kl1HMX3LmLOonsj2n7HeQ== + dependencies: + expect "^29.0.0" + pretty-format "^29.0.0" + "@types/json-schema@*", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": version "7.0.11" resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" @@ -2636,21 +2714,11 @@ resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== -"@types/log-symbols@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@types/log-symbols/-/log-symbols-2.0.0.tgz#7919e2ec3c8d13879bfdcab310dd7a3f7fc9466d" - integrity sha512-YJhbp0sz3egFFKl3BcCNPQKzuGFOP4PACcsifhK6ROGnJUW9ViYLuLybQ9GQZm7Zejy3tkGuiXYMq3GiyGkU4g== - "@types/minimatch@*": version "3.0.3" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== -"@types/mocha@^5.2.7": - version "5.2.7" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-5.2.7.tgz#315d570ccb56c53452ff8638738df60726d5b6ea" - integrity sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ== - "@types/node@*", "@types/node@^12.7.5": version "12.7.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.5.tgz#e19436e7f8e9b4601005d73673b6dc4784ffcc2f" @@ -2688,10 +2756,22 @@ resolved "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz#da4bfd73f49bd541d28920ab0e2bf0ee80f71c91" integrity sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw== -"@types/yargs@^11.1.1": - version "11.1.2" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-11.1.2.tgz#fd4b676846fe731a5de5c6d2e5ef6a377262fc30" - integrity sha512-zG61PAp2OcoIBjRV44wftJj6AJgzJrOc32LCYOBqk9bdgcdzK5DCJHV9QZJ60+Fu+fOn79g8Ks3Gixm4CfkZ+w== +"@types/stack-utils@^2.0.0": + version "2.0.1" + resolved "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c" + integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw== + +"@types/yargs-parser@*": + version "21.0.0" + resolved "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz#0c60e537fa790f5f9472ed2776c2b71ec117351b" + integrity sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA== + +"@types/yargs@^17.0.8": + version "17.0.22" + resolved "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.22.tgz#7dd37697691b5f17d020f3c63e7a45971ff71e9a" + integrity sha512-pet5WJ9U8yPVRhkwuEIp5ktAeAqRZOq4UdAyWLWzxbtpyXnzbtLdKiXAjJzi/KLmPGS9wk86lUFWZFN6sISo4g== + dependencies: + "@types/yargs-parser" "*" "@typescript-eslint/eslint-plugin@^5.50.0": version "5.50.0" @@ -3145,6 +3225,11 @@ ansi-styles@^4.1.0: "@types/color-name" "^1.1.1" color-convert "^2.0.1" +ansi-styles@^5.0.0: + version "5.2.0" + resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" + integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== + any-base@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/any-base/-/any-base-1.1.0.tgz#ae101a62bc08a597b4c9ab5b7089d456630549fe" @@ -3325,7 +3410,7 @@ arraybuffer.slice@~0.0.7: resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz#3bbc4275dd584cc1b10809b89d4e8b63a69e7675" integrity sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog== -arrify@^1.0.0, arrify@^1.0.1: +arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0= @@ -3670,7 +3755,7 @@ buffer-fill@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" integrity sha1-+PeLdniYiO858gXNY39o5wISKyw= -buffer-from@^1.0.0, buffer-from@^1.1.0: +buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== @@ -3935,6 +4020,11 @@ ci-info@^2.0.0: resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== +ci-info@^3.2.0: + version "3.7.1" + resolved "https://registry.npmjs.org/ci-info/-/ci-info-3.7.1.tgz#708a6cdae38915d597afdf3b145f2f8e1ff55f3f" + integrity sha512-4jYS4MOAaCIStSRwiuxc4B8MYhIe676yO1sYGzARnjXkWpmzZMMYxY6zu8WYWDhSuth5zhrQ1rhNSibyyvv4/w== + class-utils@^0.3.5: version "0.3.6" resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" @@ -4580,13 +4670,6 @@ decamelize@^1.1.0, decamelize@^1.1.2, decamelize@^1.2.0: resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= -decamelize@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-2.0.0.tgz#656d7bbc8094c4c788ea53c5840908c9c7d063c7" - integrity sha512-Ikpp5scV3MSYxY39ymh45ZLEecsTdv/Xj2CaQfI8RLMuwi7XvjX9H/fhraiSuU+C5w5NTDu4ZU72xNiZnurBPg== - dependencies: - xregexp "4.0.0" - decode-uri-component@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" @@ -4725,7 +4808,12 @@ didyoumean@^1.2.1: resolved "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz#989346ffe9e839b4555ecf5666edea0d3e8ad037" integrity sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw== -diff@3.5.0, diff@^3.1.0, diff@^3.2.0: +diff-sequences@^29.3.1: + version "29.3.1" + resolved "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.3.1.tgz#104b5b95fe725932421a9c6e5b4bef84c3f2249e" + integrity sha512-hlM3QR272NXCi4pq+N4Kok4kOp6EsgOM3ZSpJI7Da3UAs+Ttsi8MRmB6trM/lhyzUxGfOgnpkHtgqm5Q/CTcfQ== + +diff@3.5.0, diff@^3.2.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== @@ -5123,6 +5211,11 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +escape-string-regexp@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" + integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== + escape-string-regexp@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" @@ -5378,6 +5471,17 @@ expand-brackets@^2.1.4: snapdragon "^0.8.1" to-regex "^3.0.1" +expect@^29.0.0: + version "29.4.1" + resolved "https://registry.npmjs.org/expect/-/expect-29.4.1.tgz#58cfeea9cbf479b64ed081fd1e074ac8beb5a1fe" + integrity sha512-OKrGESHOaMxK3b6zxIq9SOW8kEXztKff/Dvg88j4xIJxur1hspEbedVkR3GpHe5LO+WB2Qw7OWN0RMTdp6as5A== + dependencies: + "@jest/expect-utils" "^29.4.1" + jest-get-type "^29.2.0" + jest-matcher-utils "^29.4.1" + jest-message-util "^29.4.1" + jest-util "^29.4.1" + express@^4.17.1: version "4.17.1" resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134" @@ -7267,6 +7371,58 @@ java-properties@^1.0.0: resolved "https://registry.yarnpkg.com/java-properties/-/java-properties-1.0.2.tgz#ccd1fa73907438a5b5c38982269d0e771fe78211" integrity sha512-qjdpeo2yKlYTH7nFdK0vbZWuTCesk4o63v5iVOlhMQPfuIZQfW/HI35SjfhA+4qpg36rnFSvUK5b1m+ckIblQQ== +jest-diff@^29.4.1: + version "29.4.1" + resolved "https://registry.npmjs.org/jest-diff/-/jest-diff-29.4.1.tgz#9a6dc715037e1fa7a8a44554e7d272088c4029bd" + integrity sha512-uazdl2g331iY56CEyfbNA0Ut7Mn2ulAG5vUaEHXycf1L6IPyuImIxSz4F0VYBKi7LYIuxOwTZzK3wh5jHzASMw== + dependencies: + chalk "^4.0.0" + diff-sequences "^29.3.1" + jest-get-type "^29.2.0" + pretty-format "^29.4.1" + +jest-get-type@^29.2.0: + version "29.2.0" + resolved "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.2.0.tgz#726646f927ef61d583a3b3adb1ab13f3a5036408" + integrity sha512-uXNJlg8hKFEnDgFsrCjznB+sTxdkuqiCL6zMgA75qEbAJjJYTs9XPrvDctrEig2GDow22T/LvHgO57iJhXB/UA== + +jest-matcher-utils@^29.4.1: + version "29.4.1" + resolved "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.4.1.tgz#73d834e305909c3b43285fbc76f78bf0ad7e1954" + integrity sha512-k5h0u8V4nAEy6lSACepxL/rw78FLDkBnXhZVgFneVpnJONhb2DhZj/Gv4eNe+1XqQ5IhgUcqj745UwH0HJmMnA== + dependencies: + chalk "^4.0.0" + jest-diff "^29.4.1" + jest-get-type "^29.2.0" + pretty-format "^29.4.1" + +jest-message-util@^29.4.1: + version "29.4.1" + resolved "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.4.1.tgz#522623aa1df9a36ebfdffb06495c7d9d19e8a845" + integrity sha512-H4/I0cXUaLeCw6FM+i4AwCnOwHRgitdaUFOdm49022YD5nfyr8C/DrbXOBEyJaj+w/y0gGJ57klssOaUiLLQGQ== + dependencies: + "@babel/code-frame" "^7.12.13" + "@jest/types" "^29.4.1" + "@types/stack-utils" "^2.0.0" + chalk "^4.0.0" + graceful-fs "^4.2.9" + micromatch "^4.0.4" + pretty-format "^29.4.1" + slash "^3.0.0" + stack-utils "^2.0.3" + +jest-util@^29.4.1: + version "29.4.1" + resolved "https://registry.npmjs.org/jest-util/-/jest-util-29.4.1.tgz#2eeed98ff4563b441b5a656ed1a786e3abc3e4c4" + integrity sha512-bQy9FPGxVutgpN4VRc0hk6w7Hx/m6L53QxpDreTZgJd9gfx/AV2MjyPde9tGyZRINAUrSv57p2inGBu2dRLmkQ== + dependencies: + "@jest/types" "^29.4.1" + "@types/node" "*" + chalk "^4.0.0" + ci-info "^3.2.0" + graceful-fs "^4.2.9" + picomatch "^2.2.3" + jest-worker@^27.4.5: version "27.5.1" resolved "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" @@ -7802,7 +7958,7 @@ lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.2. resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== -log-symbols@2.2.0, log-symbols@^2.1.0, log-symbols@^2.2.0: +log-symbols@2.2.0, log-symbols@^2.1.0: version "2.2.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" dependencies: @@ -9222,7 +9378,7 @@ picomatch@^2.0.4, picomatch@^2.0.5: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.0.7.tgz#514169d8c7cd0bdbeecc8a2609e34a7163de69f6" integrity sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA== -picomatch@^2.2.1, picomatch@^2.3.1: +picomatch@^2.2.1, picomatch@^2.2.3, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -9323,6 +9479,15 @@ prettier@^2.8.3: resolved "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz#ab697b1d3dd46fb4626fbe2f543afe0cc98d8632" integrity sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw== +pretty-format@^29.0.0, pretty-format@^29.4.1: + version "29.4.1" + resolved "https://registry.npmjs.org/pretty-format/-/pretty-format-29.4.1.tgz#0da99b532559097b8254298da7c75a0785b1751c" + integrity sha512-dt/Z761JUVsrIKaY215o1xQJBGlSmTx/h4cSqXqjHLnU1+Kt+mavVE7UgqJJO5ukx5HjSswHfmXz4LjS2oIJfg== + dependencies: + "@jest/schemas" "^29.4.0" + ansi-styles "^5.0.0" + react-is "^18.0.0" + pretty-ms@^7.0.0: version "7.0.1" resolved "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz#7d903eaab281f7d8e03c66f867e239dc32fb73e8" @@ -9496,6 +9661,11 @@ rc@^1.2.8, rc@~1.2.7: minimist "^1.2.0" strip-json-comments "~2.0.1" +react-is@^18.0.0: + version "18.2.0" + resolved "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b" + integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w== + read-cmd-shim@^1.0.1: version "1.0.4" resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-1.0.4.tgz#b4a53d43376211b45243f0072b6e603a8e37640d" @@ -10195,44 +10365,6 @@ shebang-regex@^3.0.0: resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -should-equal@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/should-equal/-/should-equal-2.0.0.tgz#6072cf83047360867e68e98b09d71143d04ee0c3" - dependencies: - should-type "^1.4.0" - -should-format@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/should-format/-/should-format-3.0.3.tgz#9bfc8f74fa39205c53d38c34d717303e277124f1" - dependencies: - should-type "^1.3.0" - should-type-adaptors "^1.0.1" - -should-type-adaptors@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz#401e7f33b5533033944d5cd8bf2b65027792e27a" - dependencies: - should-type "^1.3.0" - should-util "^1.0.0" - -should-type@^1.3.0, should-type@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/should-type/-/should-type-1.4.0.tgz#0756d8ce846dfd09843a6947719dfa0d4cff5cf3" - -should-util@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/should-util/-/should-util-1.0.0.tgz#c98cda374aa6b190df8ba87c9889c2b4db620063" - -should@^13.2.3: - version "13.2.3" - resolved "https://registry.yarnpkg.com/should/-/should-13.2.3.tgz#96d8e5acf3e97b49d89b51feaa5ae8d07ef58f10" - dependencies: - should-equal "^2.0.0" - should-format "^3.0.3" - should-type "^1.4.0" - should-type-adaptors "^1.0.1" - should-util "^1.0.0" - side-channel@^1.0.4: version "1.0.4" resolved "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" @@ -10412,13 +10544,6 @@ source-map-support@^0.5.17, source-map-support@^0.5.21, source-map-support@~0.5. buffer-from "^1.0.0" source-map "^0.6.0" -source-map-support@^0.5.6: - version "0.5.9" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f" - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - source-map-url@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" @@ -10527,6 +10652,13 @@ ssri@^8.0.0: dependencies: minipass "^3.1.1" +stack-utils@^2.0.3: + version "2.0.6" + resolved "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" + integrity sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ== + dependencies: + escape-string-regexp "^2.0.0" + static-extend@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" @@ -11107,20 +11239,6 @@ ts-node@^10.9.1: v8-compile-cache-lib "^3.0.1" yn "3.1.1" -ts-node@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-7.0.1.tgz#9562dc2d1e6d248d24bc55f773e3f614337d9baf" - integrity sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw== - dependencies: - arrify "^1.0.0" - buffer-from "^1.1.0" - diff "^3.1.0" - make-error "^1.1.1" - minimist "^1.2.0" - mkdirp "^0.5.1" - source-map-support "^0.5.6" - yn "^2.0.0" - ts-node@^9: version "9.1.1" resolved "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz#51a9a450a3e959401bda5f004a72d54b936d376d" @@ -11269,10 +11387,10 @@ typescript-memoize@^1.0.0-alpha.3: dependencies: core-js "2.4.1" -typescript@^3.1.3: - version "3.6.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.3.tgz#fea942fabb20f7e1ca7164ff626f1a9f3f70b4da" - integrity sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw== +typescript@^4.9.5: + version "4.9.5" + resolved "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" + integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== typical@^4.0.0: version "4.0.0" @@ -11818,11 +11936,6 @@ xmlhttprequest-ssl@~1.5.4: resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e" integrity sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4= -xregexp@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020" - integrity sha512-PHyM+sQouu7xspQQwELlGwwd05mXUFqwFYfqPO0cC7x4fxyHnnuetmQr6CjJiafIDoH4MogHb9dOoJzR/Y4rFg== - xtend@^4.0.0, xtend@~4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" @@ -11861,13 +11974,6 @@ yargs-parser@13.0.0: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8" - integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ== - dependencies: - camelcase "^4.1.0" - yargs-parser@^11.1.1: version "11.1.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4" @@ -11936,23 +12042,6 @@ yargs@^12.0.1, yargs@^12.0.5: y18n "^3.2.1 || ^4.0.0" yargs-parser "^11.1.1" -yargs@^12.0.2: - version "12.0.2" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.2.tgz#fe58234369392af33ecbef53819171eff0f5aadc" - dependencies: - cliui "^4.0.0" - decamelize "^2.0.0" - find-up "^3.0.0" - get-caller-file "^1.0.1" - os-locale "^3.0.0" - require-directory "^2.1.1" - require-main-filename "^1.0.1" - set-blocking "^2.0.0" - string-width "^2.0.0" - which-module "^2.0.0" - y18n "^3.2.1 || ^4.0.0" - yargs-parser "^10.1.0" - yargs@^13.2.2: version "13.3.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.0.tgz#4c657a55e07e5f2cf947f8a366567c04a0dedc83" @@ -11996,11 +12085,6 @@ yn@3.1.1: resolved "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== -yn@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" - integrity sha1-5a2ryKz0CPY4X8dklWhMiOavaJo= - yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"