You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
const chai = require('chai'); |
|
const chaiHttp = require('chai-http'); |
|
const express = require('express'); |
|
const models = require('../../../models'); |
|
import { SetupApp } from '../../../app'; |
|
import { expect } from 'chai'; |
|
import * as helpers from './helpers'; |
|
|
|
async function init() { |
|
chai.use(chaiHttp); |
|
const app = express(); |
|
SetupApp(app); |
|
await models.sequelize.sync({ force: true }); |
|
return app; |
|
} |
|
|
|
describe('POST /artist with no name', () => { |
|
it('should fail', done => { |
|
init().then((app) => { |
|
chai |
|
.request(app) |
|
.post('/artist') |
|
.send({}) |
|
.end((err, res) => { |
|
expect(err).to.be.null; |
|
expect(res).to.have.status(400); |
|
done(); |
|
}); |
|
}); |
|
}); |
|
}); |
|
|
|
describe('POST /artist with a correct request', () => { |
|
it('should succeed', done => { |
|
init().then((app) => { |
|
chai |
|
.request(app) |
|
.post('/artist') |
|
.send({ |
|
name: "MyArtist" |
|
}) |
|
.end((err, res) => { |
|
expect(err).to.be.null; |
|
expect(res).to.have.status(200); |
|
expect(res.body).to.deep.equal({ |
|
id: 1 |
|
}); |
|
done(); |
|
}); |
|
}); |
|
}); |
|
});
|
|
|