mirror of
https://github.com/directus/directus.git
synced 2026-01-31 02:37:54 -05:00
Docs for testing the API (#10275)
* mock-knex * test on the migrations run started. * test passing for run.up() * reorganize /tests/ to allow integration tests * e2e setup changes * e2e jest.config moved * e2e paths fixed, integration config * add nonadmin role and user seed+migration * auth/login w/ documentation (docs will be moved) * update user seed * add postgres10 to the ci? * argon2 saves the day * items tests passing with postgres10 support * removed comments * move generateHash out of directus_users Co-authored-by: Jay Cammarano <jaycammarano@gmail.com>
This commit is contained in:
28
api/src/tests/database/migrations/run.test.ts
Normal file
28
api/src/tests/database/migrations/run.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import knex, { Knex } from 'knex';
|
||||
import { getTracker, MockClient, Tracker } from 'knex-mock-client';
|
||||
import run from '../../../database/migrations/run';
|
||||
|
||||
describe('run', () => {
|
||||
let db: jest.Mocked<Knex>;
|
||||
let tracker: Tracker;
|
||||
|
||||
beforeAll(() => {
|
||||
db = knex({ client: MockClient }) as jest.Mocked<Knex>;
|
||||
tracker = getTracker();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
tracker.reset();
|
||||
});
|
||||
|
||||
describe('when passed the argument up', () => {
|
||||
it('returns "Nothing To Updage" if no directus_migrations', async () => {
|
||||
// note the difference between an empty array and ['Empty']
|
||||
tracker.on.select('directus_migrations').response(['Empty']);
|
||||
await run(db, 'up').catch((e: Error) => {
|
||||
expect(e).toBeInstanceOf(Error);
|
||||
expect(e.message).toBe('Nothing to upgrade');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user