#708 apply strictier linting rules (#717)

* #708 apply strictier linting rules and fix simple eslint bugs

* #708 fix eslint errors relate to promise

* #708 fix eslint import/no-extraneous-dependencies

* #708 fix eslint errors of react-hook

* #708 enable eslint check for typescript

---------

Co-authored-by: lethemanh <lethemanh@lethemanhs-MacBook-Pro.local>
This commit is contained in:
lethemanh
2026-04-01 22:15:10 +07:00
committed by GitHub
parent 2bff6aae78
commit cadfa70e60
321 changed files with 27452 additions and 27600 deletions
@@ -1,46 +1,46 @@
import { api } from "@/utils/apiUtils";
import { fetchWebSocketTicket } from "@/websocket/api/fetchWebSocketTicket";
import { api } from '@/utils/apiUtils'
import { fetchWebSocketTicket } from '@/websocket/api/fetchWebSocketTicket'
jest.mock("@/utils/apiUtils");
jest.mock('@/utils/apiUtils')
describe("fetchWebSocketTicket", () => {
describe('fetchWebSocketTicket', () => {
const mockTicket = {
clientAddress: "127.0.0.1",
value: "test-ticket-123",
generatedOn: "2025-01-12T10:00:00Z",
validUntil: "2025-01-12T11:00:00Z",
username: "testuser",
};
clientAddress: '127.0.0.1',
value: 'test-ticket-123',
generatedOn: '2025-01-12T10:00:00Z',
validUntil: '2025-01-12T11:00:00Z',
username: 'testuser'
}
beforeEach(() => {
jest.clearAllMocks();
});
jest.clearAllMocks()
})
it("should fetch ticket successfully", async () => {
(api.post as jest.Mock).mockResolvedValue({
it('should fetch ticket successfully', async () => {
;(api.post as jest.Mock).mockResolvedValue({
ok: true,
json: async () => mockTicket,
});
json: async () => mockTicket
})
const ticket = await fetchWebSocketTicket();
const ticket = await fetchWebSocketTicket()
expect(api.post).toHaveBeenCalledWith("ws/ticket");
expect(ticket).toEqual(mockTicket);
});
expect(api.post).toHaveBeenCalledWith('ws/ticket')
expect(ticket).toEqual(mockTicket)
})
it("should throw error when response is not ok", async () => {
(api.post as jest.Mock).mockResolvedValue({
ok: false,
});
it('should throw error when response is not ok', async () => {
;(api.post as jest.Mock).mockResolvedValue({
ok: false
})
await expect(fetchWebSocketTicket()).rejects.toThrow(
"Failed to fetch WebSocket ticket"
);
});
'Failed to fetch WebSocket ticket'
)
})
it("should throw error when network fails", async () => {
(api.post as jest.Mock).mockRejectedValue(new Error("Network error"));
it('should throw error when network fails', async () => {
;(api.post as jest.Mock).mockRejectedValue(new Error('Network error'))
await expect(fetchWebSocketTicket()).rejects.toThrow("Network error");
});
});
await expect(fetchWebSocketTicket()).rejects.toThrow('Network error')
})
})