2018-11-02 00:42:49 +00:00
|
|
|
// tslint:disable:object-literal-key-quotes
|
2018-11-01 02:22:32 +00:00
|
|
|
import { expect } from "chai";
|
2021-03-12 03:58:05 +00:00
|
|
|
import { SinonStub, stub } from "sinon";
|
2018-11-01 02:22:32 +00:00
|
|
|
|
2022-06-26 23:26:42 +01:00
|
|
|
import * as convenienceFunctions from "@util/convenience-functions";
|
2018-11-01 02:22:32 +00:00
|
|
|
|
|
|
|
import { Media } from "./media";
|
|
|
|
|
|
|
|
describe("Media", () => {
|
2021-03-12 03:58:05 +00:00
|
|
|
before(() => {
|
|
|
|
stub(convenienceFunctions, "uniqueId").callsFake(() => "test");
|
|
|
|
});
|
|
|
|
|
|
|
|
after(() => {
|
|
|
|
(convenienceFunctions.uniqueId as SinonStub).restore();
|
|
|
|
});
|
|
|
|
|
2023-03-17 00:20:55 +00:00
|
|
|
describe("#Array", () => {
|
|
|
|
it("Get images as array", () => {
|
2018-11-01 02:22:32 +00:00
|
|
|
const media = new Media();
|
|
|
|
|
2021-03-18 02:48:37 +00:00
|
|
|
media.addImage("test2.png", {
|
|
|
|
stream: Buffer.from(""),
|
2023-03-17 00:20:55 +00:00
|
|
|
fileName: "test2.png",
|
2021-03-18 02:48:37 +00:00
|
|
|
transformation: {
|
|
|
|
pixels: {
|
|
|
|
x: Math.round(1),
|
|
|
|
y: Math.round(1),
|
|
|
|
},
|
|
|
|
emus: {
|
|
|
|
x: Math.round(1 * 9525),
|
|
|
|
y: Math.round(1 * 9525),
|
|
|
|
},
|
2018-11-01 02:22:32 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const array = media.Array;
|
|
|
|
expect(array).to.be.an.instanceof(Array);
|
|
|
|
expect(array.length).to.equal(1);
|
|
|
|
|
|
|
|
const image = array[0];
|
|
|
|
expect(image.fileName).to.equal("test.png");
|
2021-03-15 02:41:37 +00:00
|
|
|
expect(image.transformation).to.deep.equal({
|
2018-11-01 02:22:32 +00:00
|
|
|
pixels: {
|
|
|
|
x: 100,
|
|
|
|
y: 100,
|
|
|
|
},
|
2021-03-15 02:41:37 +00:00
|
|
|
flip: {
|
|
|
|
vertical: true,
|
|
|
|
horizontal: true,
|
|
|
|
},
|
2018-11-01 02:22:32 +00:00
|
|
|
emus: {
|
|
|
|
x: 952500,
|
|
|
|
y: 952500,
|
|
|
|
},
|
2021-03-15 02:41:37 +00:00
|
|
|
rotation: 5400000,
|
2018-11-01 02:22:32 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|