tests: chat API: Move test setup to before()

This commit is contained in:
Richard Hansen 2022-04-07 19:42:06 -04:00
parent 92d70e5ead
commit 7b7b085a1c

View file

@ -13,30 +13,20 @@ const timestamp = Date.now();
const endPoint = (point) => `/api/${apiVersion}/${point}?apikey=${apiKey}`; const endPoint = (point) => `/api/${apiVersion}/${point}?apikey=${apiKey}`;
describe(__filename, function () { describe(__filename, function () {
before(async function () { agent = await common.init(); }); before(async function () {
agent = await common.init();
describe('API Versioning', function () {
it('errors if can not connect', async function () {
await agent.get('/api/') await agent.get('/api/')
.expect(200) .expect(200)
.expect((res) => { .expect((res) => {
assert(res.body.currentVersion); assert(res.body.currentVersion);
apiVersion = res.body.currentVersion; apiVersion = res.body.currentVersion;
}); });
});
});
describe('message sequence', function () {
it('createPad', async function () {
await agent.get(`${endPoint('createPad')}&padID=${padID}`) await agent.get(`${endPoint('createPad')}&padID=${padID}`)
.expect(200) .expect(200)
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
.expect((res) => { .expect((res) => {
assert.equal(res.body.code, 0); assert.equal(res.body.code, 0);
}); });
});
it('createAuthor', async function () {
await agent.get(endPoint('createAuthor')) await agent.get(endPoint('createAuthor'))
.expect(200) .expect(200)
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
@ -47,6 +37,7 @@ describe(__filename, function () {
}); });
}); });
describe('message sequence', function () {
it('appendChatMessage', async function () { it('appendChatMessage', async function () {
await agent.get(`${endPoint('appendChatMessage')}&padID=${padID}&text=blalblalbha` + await agent.get(`${endPoint('appendChatMessage')}&padID=${padID}&text=blalblalbha` +
`&authorID=${authorID}&time=${timestamp}`) `&authorID=${authorID}&time=${timestamp}`)