Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BB-692: Add test for checkValidRevisionID #963

Merged
merged 5 commits into from Mar 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 5 additions & 29 deletions test/src/server/routes/revision.js
@@ -1,49 +1,25 @@
/* eslint-disable sort-keys */

import {createEditor, truncateEntities} from '../../../test-helpers/create-entities';
import app from '../../../../src/server/app';
import chai from 'chai';
import chaiHttp from 'chai-http';
import orm from '../../../bookbrainz-data';
MonkeyDo marked this conversation as resolved.
Show resolved Hide resolved


chai.use(chaiHttp);
const {expect} = chai;
const {bookshelf, util, Revision, Gender, EditorType, Editor} = orm;

Check warning on line 11 in test/src/server/routes/revision.js

View workflow job for this annotation

GitHub Actions / ESLint

test/src/server/routes/revision.js#L11

'bookshelf' is assigned a value but never used (@typescript-eslint/no-unused-vars)

Check warning on line 11 in test/src/server/routes/revision.js

View workflow job for this annotation

GitHub Actions / ESLint

test/src/server/routes/revision.js#L11

'util' is assigned a value but never used (@typescript-eslint/no-unused-vars)

Check warning on line 11 in test/src/server/routes/revision.js

View workflow job for this annotation

GitHub Actions / ESLint

test/src/server/routes/revision.js#L11

'Gender' is assigned a value but never used (@typescript-eslint/no-unused-vars)

Check warning on line 11 in test/src/server/routes/revision.js

View workflow job for this annotation

GitHub Actions / ESLint

test/src/server/routes/revision.js#L11

'EditorType' is assigned a value but never used (@typescript-eslint/no-unused-vars)

Check warning on line 11 in test/src/server/routes/revision.js

View workflow job for this annotation

GitHub Actions / ESLint

test/src/server/routes/revision.js#L11

'Editor' is assigned a value but never used (@typescript-eslint/no-unused-vars)
MonkeyDo marked this conversation as resolved.
Show resolved Hide resolved
const revisionAttribs = {
authorId: 1,
id: 1
};

const editorData = {
genderId: 1,
id: 1,
name: 'bob',
typeId: 1
};

const genderData = {
id: 1,
name: 'test'
};
const editorTypeData = {
id: 1,
label: 'test_type'
};

describe('checkValidRevisionId', () => {
beforeEach(async () => {
await new Gender(genderData).save(null, {method: 'insert'});
await new EditorType(editorTypeData).save(null, {method: 'insert'});
await new Editor(editorData).save(null, {method: 'insert'});
before(async () => {
await createEditor(1);
await new Revision(revisionAttribs).save(null, {method: 'insert'});
});
afterEach(async () => {
await util.truncateTables(bookshelf, [
'bookbrainz.revision',
'bookbrainz.editor',
'bookbrainz.editor_type',
'musicbrainz.gender'
]);
});
after(truncateEntities);

it('should not throw an error when revision id is valid and found', async () => {
const revisionId = 1;
Expand Down