-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.test.ts
48 lines (44 loc) · 1.24 KB
/
mod.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { assert } from "jsr:@std/assert@~1/assert";
import { assertEquals } from "jsr:@std/assert@~1/equals";
import { resolve } from "jsr:@std/path@~1/resolve";
import svgMinify from "./mod.ts";
Deno.test({
name: "able to instantiate the plugin",
fn() {
const plugin = svgMinify();
assertEquals(plugin.name, "svg-minify");
assertEquals(typeof plugin.buildStart, "function");
},
});
Deno.test({
name: "able to instantiate the plugin with options",
fn() {
const plugin = svgMinify({
input: "./test.svg",
output: "./test.min.svg",
multipass: false,
});
assertEquals(plugin.name, "svg-minify");
assertEquals(typeof plugin.buildStart, "function");
},
});
Deno.test({
name: "plugin produces expected output",
async fn() {
const plugin = svgMinify({
input: "./_fixtures/input.svg",
output: "./actual.svg",
multipass: false,
silent: true,
});
assert(plugin.buildStart);
await plugin.buildStart({
build: {
outDir: resolve(Deno.cwd(), "./_fixtures"),
},
});
const actual = await Deno.readTextFile("./_fixtures/actual.svg");
const expected = await Deno.readTextFile("./_fixtures/expected.svg");
assertEquals(actual, expected);
},
});