2021-03-14 00:44:12 +00:00
|
|
|
import { expect } from "chai";
|
|
|
|
|
2021-03-19 20:53:56 +00:00
|
|
|
import { Media } from "file";
|
2021-03-14 00:44:12 +00:00
|
|
|
|
|
|
|
import { ImageReplacer } from "./image-replacer";
|
|
|
|
|
|
|
|
describe("ImageReplacer", () => {
|
|
|
|
describe("#replace()", () => {
|
|
|
|
it("should replace properly", () => {
|
|
|
|
const imageReplacer = new ImageReplacer();
|
|
|
|
const result = imageReplacer.replace(
|
|
|
|
"test {test-image.png} test",
|
|
|
|
[
|
|
|
|
{
|
|
|
|
stream: Buffer.from(""),
|
|
|
|
fileName: "test-image.png",
|
2021-03-15 02:41:37 +00:00
|
|
|
transformation: {
|
2021-03-14 00:44:12 +00:00
|
|
|
pixels: {
|
|
|
|
x: 100,
|
|
|
|
y: 100,
|
|
|
|
},
|
|
|
|
emus: {
|
|
|
|
x: 100,
|
|
|
|
y: 100,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
0,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(result).to.equal("test 0 test");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#getMediaData()", () => {
|
|
|
|
it("should get media data", () => {
|
|
|
|
const imageReplacer = new ImageReplacer();
|
2021-06-15 00:25:44 +01:00
|
|
|
const result = imageReplacer.getMediaData("test {test-image} test", {
|
2021-03-14 00:44:12 +00:00
|
|
|
Array: [
|
|
|
|
{
|
|
|
|
stream: Buffer.from(""),
|
|
|
|
fileName: "test-image",
|
|
|
|
dimensions: {
|
|
|
|
pixels: {
|
|
|
|
x: 100,
|
|
|
|
y: 100,
|
|
|
|
},
|
|
|
|
emus: {
|
|
|
|
x: 100,
|
|
|
|
y: 100,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2021-06-15 00:25:44 +01:00
|
|
|
} as unknown as Media);
|
2021-03-14 00:44:12 +00:00
|
|
|
|
|
|
|
expect(result).to.have.length(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|