mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 02:56:10 +00:00
test(categories): run the categories suite on the real database module
It resets through resetDatabase instead of the SQLite snapshot mock, so it runs in the Postgres lane as well.
This commit is contained in:
@@ -66,7 +66,6 @@
|
||||
"tests/integration/boot-sweeps-request-context.test.ts": 1,
|
||||
"tests/integration/bootstrap.test.ts": 1,
|
||||
"tests/integration/budget.test.ts": 1,
|
||||
"tests/integration/categories.test.ts": 1,
|
||||
"tests/integration/collab.test.ts": 1,
|
||||
"tests/integration/collections.test.ts": 1,
|
||||
"tests/integration/dayNotes.test.ts": 1,
|
||||
|
||||
@@ -3,24 +3,19 @@
|
||||
* Covers GET/POST/PUT/DELETE /api/categories.
|
||||
*/
|
||||
import { buildApp } from '../../src/bootstrap';
|
||||
import { db as testDb } from '../../src/db/database';
|
||||
import { Categories } from '../../src/db/entities/Categories.entity';
|
||||
import { authCookie } from '../helpers/auth';
|
||||
import type { FactoryOrm } from '../helpers/factories/context';
|
||||
import { findRow } from '../helpers/factories/rows';
|
||||
import { makeUser, makeAdmin } from '../helpers/factories/users';
|
||||
import { resetTestDb, resetRateLimits } from '../helpers/test-db';
|
||||
import { resetDatabase } from '../helpers/reset-database';
|
||||
import { resetRateLimits } from '../helpers/test-db';
|
||||
import { MikroORM } from '@mikro-orm/core';
|
||||
import type { INestApplication } from '@nestjs/common';
|
||||
|
||||
import type { Application } from 'express';
|
||||
import request from 'supertest';
|
||||
import { describe, it, expect, vi, beforeAll, beforeEach, afterAll } from 'vitest';
|
||||
|
||||
vi.mock('../../src/db/database', async () => {
|
||||
const { createSnapshotTestDb, buildDbMock } = await import('../helpers/db-mock');
|
||||
return buildDbMock(createSnapshotTestDb());
|
||||
});
|
||||
import { describe, it, expect, beforeAll, beforeEach, afterAll } from 'vitest';
|
||||
|
||||
let nestApp: INestApplication;
|
||||
let app: Application;
|
||||
@@ -41,13 +36,12 @@ async function someCategoryId(): Promise<number> {
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
resetTestDb(testDb);
|
||||
await resetDatabase(orm);
|
||||
await resetRateLimits(nestApp);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await nestApp.close();
|
||||
testDb.close();
|
||||
});
|
||||
|
||||
describe('Categories', () => {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
"tests/integration/boot-sweeps-request-context.test.ts",
|
||||
"tests/integration/bootstrap.test.ts",
|
||||
"tests/integration/budget.test.ts",
|
||||
"tests/integration/categories.test.ts",
|
||||
"tests/integration/collab.test.ts",
|
||||
"tests/integration/collections.test.ts",
|
||||
"tests/integration/dayNotes.test.ts",
|
||||
|
||||
Reference in New Issue
Block a user