-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccessible-challenges-service.test.ts
More file actions
42 lines (36 loc) · 1.37 KB
/
accessible-challenges-service.test.ts
File metadata and controls
42 lines (36 loc) · 1.37 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
import { AccessibleChallengesService } from "../../../app/challenges-platform";
import { accessibleChallengeFactory } from "../factories/accessible-challenge-factory";
import { challengeFactory } from "../factories/challenge-factory";
import { participantFactory } from "../factories/participant-factory";
describe("AccessibleChallengesService", () => {
describe("count", () => {
describe("when the challenge is not accessible to the participant", () => {
it("returns 0", async () => {
const challenge = await challengeFactory();
const participant = await participantFactory();
const result = await AccessibleChallengesService.count(
challenge,
participant,
);
if (!result.ok) fail("Expected result to be Ok");
expect(result.val).toBe(0);
});
});
describe("when the challenge is accessible to the participant", () => {
it("returns 1", async () => {
const challenge = await challengeFactory();
const participant = await participantFactory();
await accessibleChallengeFactory({
challenge,
participant,
});
const result = await AccessibleChallengesService.count(
challenge,
participant,
);
if (!result.ok) fail("Expected result to be Ok");
expect(result.val).toBe(1);
});
});
});
});