forked from NagRock/ts-mockito
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMethodAction.spec.ts
38 lines (33 loc) · 1.43 KB
/
MethodAction.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
import {MethodAction} from "../src/MethodAction";
import {strictEqual} from "../src/ts-mockito";
describe("MethodAction", () => {
describe("checking if method with matchers is applicable", () => {
describe("when all matchers match", () => {
it("returns true", () => {
// given
const methodName = "sampleMethodName";
const firstArg = 5;
const secondArg = "sampleString";
const testObj: MethodAction = new MethodAction(methodName, [firstArg, secondArg]);
// when
const result = testObj.isApplicable(methodName, [strictEqual(firstArg), strictEqual(secondArg)]);
// then
expect(result).toBeTruthy();
});
});
describe("when one matcher doesn`t match", () => {
it("returns false", () => {
// given
const methodName = "sampleMethodName";
const firstArg = 5;
const secondArg = "sampleString";
const notMatchingArg = "notMatchingArg";
const testObj: MethodAction = new MethodAction(methodName, [firstArg, notMatchingArg]);
// when
const result = testObj.isApplicable(methodName, [strictEqual(firstArg), strictEqual(secondArg)]);
// then
expect(result).toBeFalsy();
});
});
});
});