mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 15:44:45 -04:00
feat(test-setup): restructure to synchronous builder
The previous pattern used async methods for the builder pattern, which were hideous to use when chained multiple times. This extracts the builder into a separate class and uses normal functions in the builder. These queue async functions in arrays, which are executed at the correct time, when the new async `build` function is called. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
8f1aeab934
commit
d1dbd1bb22
13 changed files with 156 additions and 84 deletions
|
@ -7,8 +7,7 @@ import request from 'supertest';
|
|||
|
||||
import { AliasCreateDto } from '../../src/notes/alias-create.dto';
|
||||
import { AliasUpdateDto } from '../../src/notes/alias-update.dto';
|
||||
import { User } from '../../src/users/user.entity';
|
||||
import { TestSetup } from '../test-setup';
|
||||
import { TestSetup, TestSetupBuilder } from '../test-setup';
|
||||
|
||||
describe('Alias', () => {
|
||||
let testSetup: TestSetup;
|
||||
|
@ -17,7 +16,7 @@ describe('Alias', () => {
|
|||
let forbiddenNoteId: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
testSetup = await (await TestSetup.create(false)).withUsers();
|
||||
testSetup = await TestSetupBuilder.create().withUsers().withNotes().build();
|
||||
forbiddenNoteId =
|
||||
testSetup.configService.get('appConfig').forbiddenNoteIds[0];
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import { HistoryEntryUpdateDto } from '../../src/history/history-entry-update.dt
|
|||
import { HistoryEntryDto } from '../../src/history/history-entry.dto';
|
||||
import { NoteMetadataDto } from '../../src/notes/note-metadata.dto';
|
||||
import { User } from '../../src/users/user.entity';
|
||||
import { TestSetup } from '../test-setup';
|
||||
import { TestSetup, TestSetupBuilder } from '../test-setup';
|
||||
|
||||
// TODO Tests have to be reworked using UserService functions
|
||||
|
||||
|
@ -22,7 +22,7 @@ describe('Me', () => {
|
|||
let user: User;
|
||||
|
||||
beforeAll(async () => {
|
||||
testSetup = await TestSetup.create();
|
||||
testSetup = await TestSetupBuilder.create().withMockAuth().build();
|
||||
|
||||
uploadPath =
|
||||
testSetup.configService.get('mediaConfig').backend.filesystem.uploadPath;
|
||||
|
|
|
@ -10,7 +10,7 @@ import request from 'supertest';
|
|||
import { ConsoleLoggerService } from '../../src/logger/console-logger.service';
|
||||
import { Note } from '../../src/notes/note.entity';
|
||||
import { User } from '../../src/users/user.entity';
|
||||
import { TestSetup } from '../test-setup';
|
||||
import { TestSetup, TestSetupBuilder } from '../test-setup';
|
||||
import { ensureDeleted } from '../utils';
|
||||
|
||||
describe('Media', () => {
|
||||
|
@ -20,7 +20,7 @@ describe('Media', () => {
|
|||
let user: User;
|
||||
|
||||
beforeAll(async () => {
|
||||
testSetup = await TestSetup.create();
|
||||
testSetup = await TestSetupBuilder.create().withMockAuth().build();
|
||||
|
||||
uploadPath =
|
||||
testSetup.configService.get('mediaConfig').backend.filesystem.uploadPath;
|
||||
|
|
|
@ -10,7 +10,7 @@ import request from 'supertest';
|
|||
import { NotInDBError } from '../../src/errors/errors';
|
||||
import { NotePermissionsUpdateDto } from '../../src/notes/note-permissions.dto';
|
||||
import { User } from '../../src/users/user.entity';
|
||||
import { TestSetup } from '../test-setup';
|
||||
import { TestSetup, TestSetupBuilder } from '../test-setup';
|
||||
|
||||
describe('Notes', () => {
|
||||
let testSetup: TestSetup;
|
||||
|
@ -23,7 +23,7 @@ describe('Notes', () => {
|
|||
let testImage: Buffer;
|
||||
|
||||
beforeAll(async () => {
|
||||
testSetup = await TestSetup.create();
|
||||
testSetup = await TestSetupBuilder.create().withMockAuth().build();
|
||||
|
||||
forbiddenNoteId =
|
||||
testSetup.configService.get('appConfig').forbiddenNoteIds[0];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue