|
|
@ -13,12 +13,12 @@ async function init() { |
|
|
|
return app; |
|
|
|
return app; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
describe('POST /song/create with no title', () => { |
|
|
|
describe('POST /song with no title', () => { |
|
|
|
it('should fail', done => { |
|
|
|
it('should fail', done => { |
|
|
|
init().then((app) => { |
|
|
|
init().then((app) => { |
|
|
|
chai |
|
|
|
chai |
|
|
|
.request(app) |
|
|
|
.request(app) |
|
|
|
.post('/song/create') |
|
|
|
.post('/song') |
|
|
|
.send({}) |
|
|
|
.send({}) |
|
|
|
.end((err, res) => { |
|
|
|
.end((err, res) => { |
|
|
|
expect(err).to.be.null; |
|
|
|
expect(err).to.be.null; |
|
|
@ -29,12 +29,12 @@ describe('POST /song/create with no title', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('POST /song/create with only a title', () => { |
|
|
|
describe('POST /song with only a title', () => { |
|
|
|
it('should return the first available id', done => { |
|
|
|
it('should return the first available id', done => { |
|
|
|
init().then((app) => { |
|
|
|
init().then((app) => { |
|
|
|
chai |
|
|
|
chai |
|
|
|
.request(app) |
|
|
|
.request(app) |
|
|
|
.post('/song/create') |
|
|
|
.post('/song') |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
title: "MySong" |
|
|
|
title: "MySong" |
|
|
|
}) |
|
|
|
}) |
|
|
@ -50,12 +50,12 @@ describe('POST /song/create with only a title', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('POST /song/create with a nonexistent artist Id', () => { |
|
|
|
describe('POST /song with a nonexistent artist Id', () => { |
|
|
|
it('should fail', done => { |
|
|
|
it('should fail', done => { |
|
|
|
init().then((app) => { |
|
|
|
init().then((app) => { |
|
|
|
chai |
|
|
|
chai |
|
|
|
.request(app) |
|
|
|
.request(app) |
|
|
|
.post('/song/create') |
|
|
|
.post('/song') |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
title: "MySong", |
|
|
|
title: "MySong", |
|
|
|
artistIds: [1] |
|
|
|
artistIds: [1] |
|
|
@ -69,12 +69,12 @@ describe('POST /song/create with a nonexistent artist Id', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('POST /song/create with an existing artist Id', () => { |
|
|
|
describe('POST /song with an existing artist Id', () => { |
|
|
|
it('should succeed', done => { |
|
|
|
it('should succeed', done => { |
|
|
|
init().then((app) => { |
|
|
|
init().then((app) => { |
|
|
|
async function createArtist() { |
|
|
|
async function createArtist() { |
|
|
|
await chai.request(app) |
|
|
|
await chai.request(app) |
|
|
|
.post('/artist/create') |
|
|
|
.post('/artist') |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
name: "MyArtist" |
|
|
|
name: "MyArtist" |
|
|
|
}) |
|
|
|
}) |
|
|
@ -88,7 +88,7 @@ describe('POST /song/create with an existing artist Id', () => { |
|
|
|
|
|
|
|
|
|
|
|
async function createSong() { |
|
|
|
async function createSong() { |
|
|
|
chai.request(app) |
|
|
|
chai.request(app) |
|
|
|
.post('/song/create') |
|
|
|
.post('/song') |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
title: "MySong", |
|
|
|
title: "MySong", |
|
|
|
artistIds: [1] |
|
|
|
artistIds: [1] |
|
|
@ -109,12 +109,12 @@ describe('POST /song/create with an existing artist Id', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('POST /song/create with two existing artist Ids', () => { |
|
|
|
describe('POST /song with two existing artist Ids', () => { |
|
|
|
it('should succeed', done => { |
|
|
|
it('should succeed', done => { |
|
|
|
init().then((app) => { |
|
|
|
init().then((app) => { |
|
|
|
async function createArtist(name, expectId) { |
|
|
|
async function createArtist(name, expectId) { |
|
|
|
await chai.request(app) |
|
|
|
await chai.request(app) |
|
|
|
.post('/artist/create') |
|
|
|
.post('/artist') |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
name: name |
|
|
|
name: name |
|
|
|
}) |
|
|
|
}) |
|
|
@ -128,7 +128,7 @@ describe('POST /song/create with two existing artist Ids', () => { |
|
|
|
|
|
|
|
|
|
|
|
async function createSong() { |
|
|
|
async function createSong() { |
|
|
|
chai.request(app) |
|
|
|
chai.request(app) |
|
|
|
.post('/song/create') |
|
|
|
.post('/song') |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
title: "MySong", |
|
|
|
title: "MySong", |
|
|
|
artistIds: [1, 2] |
|
|
|
artistIds: [1, 2] |
|
|
@ -150,12 +150,12 @@ describe('POST /song/create with two existing artist Ids', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('POST /song/create with an existent and a nonexistent artist Id', () => { |
|
|
|
describe('POST /song with an existent and a nonexistent artist Id', () => { |
|
|
|
it('should fail', done => { |
|
|
|
it('should fail', done => { |
|
|
|
init().then((app) => { |
|
|
|
init().then((app) => { |
|
|
|
async function createArtist(name, expectId) { |
|
|
|
async function createArtist(name, expectId) { |
|
|
|
await chai.request(app) |
|
|
|
await chai.request(app) |
|
|
|
.post('/artist/create') |
|
|
|
.post('/artist') |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
name: name |
|
|
|
name: name |
|
|
|
}) |
|
|
|
}) |
|
|
@ -169,7 +169,7 @@ describe('POST /song/create with an existent and a nonexistent artist Id', () => |
|
|
|
|
|
|
|
|
|
|
|
async function createSong() { |
|
|
|
async function createSong() { |
|
|
|
chai.request(app) |
|
|
|
chai.request(app) |
|
|
|
.post('/song/create') |
|
|
|
.post('/song') |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
title: "MySong", |
|
|
|
title: "MySong", |
|
|
|
artistIds: [1, 2] |
|
|
|
artistIds: [1, 2] |
|
|
|