-
Notifications
You must be signed in to change notification settings - Fork 990
/
Copy pathfilterTargets.spec.ts
53 lines (48 loc) · 1.27 KB
/
filterTargets.spec.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
import { expect } from "chai";
import { filterTargets } from "./filterTargets";
import { Options } from "./options";
import { RC } from "./rc";
const SAMPLE_OPTIONS: Options = {
cwd: "/",
configPath: "/",
/* eslint-disable-next-line */
config: {} as any,
only: "",
except: "",
nonInteractive: false,
json: false,
interactive: false,
debug: false,
force: false,
filteredTargets: [],
rc: new RC(),
};
const VALID_TARGETS = ["hosting", "functions"];
describe("filterTargets", () => {
it("should leave targets alone if no filtering is specified", () => {
const o = Object.assign(SAMPLE_OPTIONS, {
config: {
has: () => true,
},
});
expect(filterTargets(o, VALID_TARGETS)).to.deep.equal(["hosting", "functions"]);
});
it("should filter targets from --only", () => {
const o = Object.assign(SAMPLE_OPTIONS, {
config: {
has: () => true,
},
only: "hosting",
});
expect(filterTargets(o, VALID_TARGETS)).to.deep.equal(["hosting"]);
});
it("should filter out targets with --except", () => {
const o = Object.assign(SAMPLE_OPTIONS, {
config: {
has: () => true,
},
except: "functions",
});
expect(filterTargets(o, VALID_TARGETS)).to.deep.equal(["hosting"]);
});
});