Skip to content

Commit ced8585

Browse files
committed
Update formatting
1 parent 02aef00 commit ced8585

File tree

5 files changed

+77
-31
lines changed

5 files changed

+77
-31
lines changed

test/infrastructure/discord/commands/createIssue.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { ItemService } from "@src/items/services";
22
import { Ok, Err } from "ts-results";
3-
import { execute, handleModalSubmit } from "@infrastructure/discord/commands/createIssue";
3+
import {
4+
execute,
5+
handleModalSubmit,
6+
} from "@infrastructure/discord/commands/createIssue";
47
import { promptAssigneeSelection } from "@infrastructure/discord/interactions";
58
import { can } from "@infrastructure/discord/authz";
6-
import {
7-
CommandInteraction,
8-
ModalSubmitInteraction,
9-
} from "discord.js";
9+
import { CommandInteraction, ModalSubmitInteraction } from "discord.js";
1010

1111
jest.mock("@src/items/services", () => ({
1212
ItemService: {
@@ -75,9 +75,9 @@ describe("create-issue slash command", () => {
7575
key === "dueDate" ? "bad-date" : "test value",
7676
);
7777

78-
await expect(() =>
79-
handleModalSubmit(interaction),
80-
).rejects.toThrow("Invalid due date format. Please use yyyy-mm-dd.");
78+
await expect(() => handleModalSubmit(interaction)).rejects.toThrow(
79+
"Invalid due date format. Please use yyyy-mm-dd.",
80+
);
8181
});
8282

8383
it("will handle error from ItemService.create", async () => {

test/infrastructure/discord/commands/myIssues.test.ts

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ describe("my-issues command", () => {
6969
(can as jest.Mock).mockReturnValue(true);
7070
const interaction = makeInteraction();
7171
interaction.user.id = "not-in-map";
72-
jest.spyOn(Object, 'values').mockReturnValueOnce([{
73-
githubUsername: "test-user",
74-
discordId: "someone-else",
75-
githubId: "123",
76-
}]);
72+
jest.spyOn(Object, "values").mockReturnValueOnce([
73+
{
74+
githubUsername: "test-user",
75+
discordId: "someone-else",
76+
githubId: "123",
77+
},
78+
]);
7779

7880
await execute(interaction as any);
7981

@@ -85,8 +87,15 @@ describe("my-issues command", () => {
8587

8688
it("will show error if GitHub API fails", async () => {
8789
(can as jest.Mock).mockReturnValue(true);
88-
jest.spyOn(Object, 'values').mockReturnValue([{ githubUsername: "test-user", discordId: "user-123" }]);
89-
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({ err: true, val: { message: "Boom" } });
90+
jest
91+
.spyOn(Object, "values")
92+
.mockReturnValue([
93+
{ githubUsername: "test-user", discordId: "user-123" },
94+
]);
95+
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({
96+
err: true,
97+
val: { message: "Boom" },
98+
});
9099

91100
const interaction = makeInteraction();
92101

@@ -99,8 +108,15 @@ describe("my-issues command", () => {
99108

100109
it("will show message if no assigned issues are found", async () => {
101110
(can as jest.Mock).mockReturnValue(true);
102-
jest.spyOn(Object, 'values').mockReturnValue([{ githubUsername: "test-user", discordId: "user-123" }]);
103-
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({ err: false, val: [] });
111+
jest
112+
.spyOn(Object, "values")
113+
.mockReturnValue([
114+
{ githubUsername: "test-user", discordId: "user-123" },
115+
]);
116+
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({
117+
err: false,
118+
val: [],
119+
});
104120

105121
const interaction = makeInteraction();
106122

@@ -113,7 +129,11 @@ describe("my-issues command", () => {
113129

114130
it("will show a specific issue by index", async () => {
115131
(can as jest.Mock).mockReturnValue(true);
116-
jest.spyOn(Object, 'values').mockReturnValue([{ githubUsername: "test-user", discordId: "user-123" }]);
132+
jest
133+
.spyOn(Object, "values")
134+
.mockReturnValue([
135+
{ githubUsername: "test-user", discordId: "user-123" },
136+
]);
117137
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({
118138
err: false,
119139
val: [defaultItem({ assignedUsers: ["https://github.com/test-user"] })],
@@ -131,7 +151,11 @@ describe("my-issues command", () => {
131151

132152
it("will show index list when no index is provided", async () => {
133153
(can as jest.Mock).mockReturnValue(true);
134-
jest.spyOn(Object, 'values').mockReturnValue([{ githubUsername: "test-user", discordId: "user-123" }]);
154+
jest
155+
.spyOn(Object, "values")
156+
.mockReturnValue([
157+
{ githubUsername: "test-user", discordId: "user-123" },
158+
]);
135159
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({
136160
err: false,
137161
val: [defaultItem({ assignedUsers: ["https://github.com/test-user"] })],
@@ -142,7 +166,7 @@ describe("my-issues command", () => {
142166
await execute(interaction as any);
143167

144168
expect(mockEditReply).toHaveBeenCalledWith({
145-
content: expect.stringContaining("assigned issue(s):\n\n\`0\`"),
169+
content: expect.stringContaining("assigned issue(s):\n\n`0`"),
146170
});
147171
});
148172
});

test/infrastructure/discord/commands/unassignedIssues.test.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ describe("unassigned-issues command", () => {
7575

7676
it("will show error if GitHub API fails", async () => {
7777
(can as jest.Mock).mockReturnValue(true);
78-
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({ err: true, val: { message: "fail" } });
78+
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({
79+
err: true,
80+
val: { message: "fail" },
81+
});
7982

8083
const interaction = makeInteraction();
8184
await execute(interaction as any);
@@ -87,7 +90,10 @@ describe("unassigned-issues command", () => {
8790

8891
it("will show message if no unassigned issues are found", async () => {
8992
(can as jest.Mock).mockReturnValue(true);
90-
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({ err: false, val: [] });
93+
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({
94+
err: false,
95+
val: [],
96+
});
9197
(filterForUnassigned as jest.Mock).mockReturnValue([]);
9298

9399
const interaction = makeInteraction();
@@ -100,7 +106,10 @@ describe("unassigned-issues command", () => {
100106

101107
it("will return a specific unassigned issue by index", async () => {
102108
(can as jest.Mock).mockReturnValue(true);
103-
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({ err: false, val: [defaultItem()] });
109+
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({
110+
err: false,
111+
val: [defaultItem()],
112+
});
104113
(filterForUnassigned as jest.Mock).mockReturnValue([defaultItem()]);
105114

106115
const interaction = makeInteraction({ getInteger: () => 0 });
@@ -114,14 +123,17 @@ describe("unassigned-issues command", () => {
114123

115124
it("will show an index list of unassigned issues when no index is provided", async () => {
116125
(can as jest.Mock).mockReturnValue(true);
117-
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({ err: false, val: [defaultItem()] });
126+
(GithubAPI.fetchProjectItems as jest.Mock).mockResolvedValue({
127+
err: false,
128+
val: [defaultItem()],
129+
});
118130
(filterForUnassigned as jest.Mock).mockReturnValue([defaultItem()]);
119131

120132
const interaction = makeInteraction();
121133
await execute(interaction as any);
122134

123135
expect(mockEditReply).toHaveBeenCalledWith({
124-
content: expect.stringContaining("unassigned issue(s) found:\n\n\`0\`"),
136+
content: expect.stringContaining("unassigned issue(s) found:\n\n`0`"),
125137
});
126138
});
127139
});

test/infrastructure/discord/interactions/issueButtonInteraction.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { issueButtonInteraction } from "@infrastructure/discord/interactions/issueButtonInteraction";
22
import { promptAssigneeSelection } from "@infrastructure/discord/interactions/promptAssigneeSelection";
33

4-
jest.mock("@infrastructure/discord/interactions/promptAssigneeSelection", () => ({
5-
promptAssigneeSelection: jest.fn(),
6-
}));
4+
jest.mock(
5+
"@infrastructure/discord/interactions/promptAssigneeSelection",
6+
() => ({
7+
promptAssigneeSelection: jest.fn(),
8+
}),
9+
);
710

811
describe("issueButtonInteraction", () => {
912
const mockReply = jest.fn();
@@ -55,7 +58,10 @@ describe("issueButtonInteraction", () => {
5558

5659
await issueButtonInteraction(interaction);
5760

58-
expect(promptAssigneeSelection).toHaveBeenCalledWith(interaction, "abc-123");
61+
expect(promptAssigneeSelection).toHaveBeenCalledWith(
62+
interaction,
63+
"abc-123",
64+
);
5965
});
6066

6167
it("will respond with delete message", async () => {

test/items/services/ItemService.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ describe("updateAssignee", () => {
111111

112112
it("will return success if GitHubAPI.updateProjectItemAssignee succeeds", async () => {
113113
const mockResult = Ok({ status: "success" });
114-
(GithubAPI.updateProjectItemAssignee as jest.Mock).mockResolvedValue(mockResult);
114+
(GithubAPI.updateProjectItemAssignee as jest.Mock).mockResolvedValue(
115+
mockResult,
116+
);
115117

116118
const result = await ItemService.updateAssignee({ assigneeId, itemId });
117119

@@ -125,7 +127,9 @@ describe("updateAssignee", () => {
125127

126128
it("will return error if GitHubAPI.updateProjectItemAssignee fails", async () => {
127129
const error = new Error("updateProjectItemAssignee failed");
128-
(GithubAPI.updateProjectItemAssignee as jest.Mock).mockResolvedValue(Err(error));
130+
(GithubAPI.updateProjectItemAssignee as jest.Mock).mockResolvedValue(
131+
Err(error),
132+
);
129133

130134
const result = await ItemService.updateAssignee({ assigneeId, itemId });
131135

0 commit comments

Comments
 (0)