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.
 
 
 
 

173 lines
4.0 KiB

import { expect } from "chai";
export async function createSong(
req,
props = { title: "Song" },
expectStatus = undefined,
expectResponse = undefined
) {
await req
.post('/song')
.send(props)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
expectResponse && expect(res.body).to.deep.equal(expectResponse);
});
}
export async function modifySong(
req,
id = 1,
props = { name: "NewSong" },
expectStatus = undefined,
) {
await req
.put('/song/' + id)
.send(props)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
});
}
export async function checkSong(
req,
id,
expectStatus = undefined,
expectResponse = undefined,
) {
await req
.get('/song/' + id)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
expectResponse && expect(res.body).to.deep.equal(expectResponse);
})
}
export async function createArtist(
req,
props = { name: "Artist" },
expectStatus = undefined,
expectResponse = undefined
) {
await req
.post('/artist')
.send(props)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
expectResponse && expect(res.body).to.deep.equal(expectResponse);
});
}
export async function modifyArtist(
req,
id = 1,
props = { name: "NewArtist" },
expectStatus = undefined,
) {
await req
.put('/artist/' + id)
.send(props)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
});
}
export async function checkArtist(
req,
id,
expectStatus = undefined,
expectResponse = undefined,
) {
await req
.get('/artist/' + id)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
expectResponse && expect(res.body).to.deep.equal(expectResponse);
})
}
export async function createTag(
req,
props = { name: "Tag" },
expectStatus = undefined,
expectResponse = undefined
) {
await req
.post('/tag')
.send(props)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
expectResponse && expect(res.body).to.deep.equal(expectResponse);
});
}
export async function modifyTag(
req,
id = 1,
props = { name: "NewTag" },
expectStatus = undefined,
) {
await req
.put('/tag/' + id)
.send(props)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
});
}
export async function checkTag(
req,
id,
expectStatus = undefined,
expectResponse = undefined,
) {
await req
.get('/tag/' + id)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
expectResponse && expect(res.body).to.deep.equal(expectResponse);
})
}
export async function createAlbum(
req,
props = { name: "Album" },
expectStatus = undefined,
expectResponse = undefined
) {
await req
.post('/album')
.send(props)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
expectResponse && expect(res.body).to.deep.equal(expectResponse);
});
}
export async function modifyAlbum(
req,
id = 1,
props = { name: "NewAlbum" },
expectStatus = undefined,
) {
await req
.put('/album/' + id)
.send(props)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
});
}
export async function checkAlbum(
req,
id,
expectStatus = undefined,
expectResponse = undefined,
) {
await req
.get('/album/' + id)
.then((res) => {
expectStatus && expect(res).to.have.status(expectStatus);
expectResponse && expect(res.body).to.deep.equal(expectResponse);
})
}