Skip to content

Commit

Permalink
force test fail
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsc0301 committed Sep 12, 2023
1 parent e1772b5 commit 0f476e1
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions tests/server.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
import { expect, test } from 'bun:test';
import { describe, expect, test } from 'bun:test';
import * as server from '../index';

test('server status', async () => {
expect((await fetch(`http://localhost:${server.PORT}/`)).status).toBe(200)
});
describe('server', () => {
test('status', async () => {
expect((await fetch(`http://localhost:${server.PORT}/`)).status).toBe(200)
});

let room_id = '';
test('server login', async () => {
const response = await (await fetch(`http://localhost:${server.PORT}/login?player_email=bun-test`)).json();
room_id = response.data._ID;
expect(room_id === undefined).toBe(false);
expect(response.data.players['bun-test'].username).toBe('bun-test');
});
let room_id = '';
test('login', async () => {
const response = await (await fetch(`http://localhost:${server.PORT}/login?player_email=bun-test`)).json();
room_id = response.data._ID;
expect(room_id === undefined).toBe(false);
expect(response.data.players['bun-test'].username).toBe('bun-test');
});

test('server logout', async () => {
const response = await fetch(`http://localhost:${server.PORT}/logout?player_email=bun-test&room_id=${room_id}`);
expect(response.status).toBe(200);
test('logout', async () => {
const response = await fetch(`http://localhost:${server.PORT}/logout?player_email=bun-test&room_id=${room_id}`);
expect(response.status).toBe(200);
});

test.todo('force unknown path', async () => {
const response = await fetch(`http://localhost:${server.PORT}/unknown-path`);
expect(response.status).toBe(404);
});

test('force unknown method', async () => {
const response = await fetch(`http://localhost:${server.PORT}/`, { method: 'PUT' });
expect(response.status).toBe(405);

Check failure on line 29 in tests/server.test.ts

View workflow job for this annotation

GitHub Actions / Server Tests

error: expect(received).toBe(expected)

Expected: 405 Received: 404 at /home/runner/work/best-multiplayer-game-possible/best-multiplayer-game-possible/tests/server.test.ts:29:4 at processTicksAndRejections (:1:2602)
});
});

0 comments on commit 0f476e1

Please sign in to comment.