-
Notifications
You must be signed in to change notification settings - Fork 427
Expand file tree
/
Copy pathauthor.spec.ts
More file actions
75 lines (58 loc) · 2.35 KB
/
author.spec.ts
File metadata and controls
75 lines (58 loc) · 2.35 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { DefaultProcessorOptions } from "../../__tests__/constants/default-processor-options";
import { generateIIssue } from "../../__tests__/functions/generate-iissue";
import { IIssue } from "../interfaces/issue";
import { IIssuesProcessorOptions } from "../interfaces/issues-processor-options";
import { Author } from "./author";
import { Issue } from "./issue";
describe("Authors", (): void => {
let author: Author;
let optionsInterface: IIssuesProcessorOptions;
let issue: Issue;
let issueInterface: IIssue;
beforeEach((): void => {
optionsInterface = {
...DefaultProcessorOptions,
};
issueInterface = generateIIssue();
});
describe("should exempt", (): void => {
it("because issue.user is one of options.anyOfAuthors", (): void => {
optionsInterface.anyOfAuthors = "foo,bar,foobar123";
issueInterface.user = { type: "User", login: "foobar123" };
expect.assertions(1);
issue = new Issue(optionsInterface, issueInterface);
author = new Author(optionsInterface, issue);
const result = author.shouldExemptAuthor();
expect(result).toStrictEqual(true);
});
});
describe("should not exempt", (): void => {
it("because options.anyOfAuthors is not set", (): void => {
optionsInterface.anyOfAuthors = "";
issueInterface.user = null;
expect.assertions(1);
issue = new Issue(optionsInterface, issueInterface);
author = new Author(optionsInterface, issue);
const result = author.shouldExemptAuthor();
expect(result).toStrictEqual(false);
});
it("because issue.user is not set", (): void => {
optionsInterface.anyOfAuthors = "foo,bar";
issueInterface.user = null;
expect.assertions(1);
issue = new Issue(optionsInterface, issueInterface);
author = new Author(optionsInterface, issue);
const result = author.shouldExemptAuthor();
expect(result).toStrictEqual(false);
});
it("because issue.user is not one of options.anyOfAuthors", (): void => {
optionsInterface.anyOfAuthors = "foo,bar";
issueInterface.user = { type: "User", login: "foobar123" };
expect.assertions(1);
issue = new Issue(optionsInterface, issueInterface);
author = new Author(optionsInterface, issue);
const result = author.shouldExemptAuthor();
expect(result).toStrictEqual(false);
});
});
});