-
Notifications
You must be signed in to change notification settings - Fork 1
/
unit.ts
59 lines (51 loc) · 1.66 KB
/
unit.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
49
50
51
52
53
54
55
56
57
58
59
import { Step } from "@shanzhai/interfaces";
import { typeScriptSourceStore } from "@shanzhai/type-script-source-store";
import { ReadTextFileStep } from "@shanzhai/read-text-file-step";
import { DeleteFromKeyedStoreStep } from "@shanzhai/delete-from-keyed-store-step";
import { KeyedStoreSetOutput } from "@shanzhai/keyed-store-set-output";
import readTypeScriptFilesPlugin = require(".");
describe(`read-type-script-files-plugin`, () => {
it(`matches *.ts files`, () => {
expect(readTypeScriptFilesPlugin.triggers.readTypeScriptFiles.glob).toEqual(
`**/*.ts`
);
});
it(`advertises the stores it will write to`, () => {
expect(
expect(
readTypeScriptFilesPlugin.triggers.readTypeScriptFiles.writesToStores
).toEqual(jasmine.arrayWithExactContents([typeScriptSourceStore]))
);
});
describe(`when a file is removed`, () => {
let step: Step;
beforeAll(() => {
step =
readTypeScriptFilesPlugin.triggers.readTypeScriptFiles.down(
`Test Full Path`
);
});
it(`deletes the read file from the store`, () => {
expect(step).toEqual(
new DeleteFromKeyedStoreStep(typeScriptSourceStore, `Test Full Path`)
);
});
});
describe(`when a file is added`, () => {
let step: Step;
beforeAll(() => {
step =
readTypeScriptFilesPlugin.triggers.readTypeScriptFiles.up(
`Test Full Path`
);
});
it(`reads the file into the store`, () => {
expect(step).toEqual(
new ReadTextFileStep(
[`src`, `Test Full Path`],
new KeyedStoreSetOutput(typeScriptSourceStore, `Test Full Path`)
)
);
});
});
});