2020-01-18 22:15:44 +00:00
|
|
|
const apiRoomSpec = (chai, knex, server) => {
|
2020-01-18 23:42:45 +00:00
|
|
|
const roomEndpoint = '/api/v1/rooms';
|
2020-01-18 23:49:35 +00:00
|
|
|
const publicRooms = {rooms: [{id: 1, name: 'main', description: 'A general place to play Go', language: 'EN'}]};
|
2020-01-22 00:01:35 +00:00
|
|
|
const roomOne = {
|
2020-01-23 22:46:49 +00:00
|
|
|
currentRoom: {
|
2020-01-22 00:01:35 +00:00
|
|
|
id: 1,
|
|
|
|
name: 'main',
|
|
|
|
description: 'A general place to play Go',
|
2020-01-23 22:46:49 +00:00
|
|
|
language: 'EN'
|
|
|
|
},
|
2020-01-24 05:25:08 +00:00
|
|
|
roomGames: [
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
komi: 6.5,
|
|
|
|
handicap: 0,
|
|
|
|
board_size: 19,
|
2020-01-24 08:07:40 +00:00
|
|
|
player_black: 'user-one',
|
|
|
|
player_white: 'user-two',
|
|
|
|
player_black_rank: 'UR',
|
|
|
|
player_white_rank: 'UR',
|
2020-01-24 05:25:08 +00:00
|
|
|
open: false,
|
|
|
|
win_type: null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
komi: 6.5,
|
|
|
|
handicap: 0,
|
|
|
|
board_size: 19,
|
|
|
|
player_black: 'user-one',
|
|
|
|
player_white: null,
|
|
|
|
player_black_rank: 'UR',
|
|
|
|
player_white_rank: 'UR',
|
|
|
|
open: true,
|
|
|
|
win_type: null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 3,
|
|
|
|
komi: 6.5,
|
|
|
|
handicap: 0,
|
|
|
|
board_size: 19,
|
|
|
|
player_black: 'Ishida Yoshio',
|
|
|
|
player_white: 'Rin Kaiho',
|
|
|
|
player_black_rank: 'D7',
|
|
|
|
player_white_rank: 'D9',
|
|
|
|
open: false,
|
|
|
|
win_type: 'B+'
|
|
|
|
}
|
|
|
|
],
|
2020-01-22 01:02:54 +00:00
|
|
|
messages: [ {
|
|
|
|
content: 'Hey! Welcome to the general room!',
|
|
|
|
username: 'user-one',
|
|
|
|
admin: true
|
2020-01-22 00:01:35 +00:00
|
|
|
} ]
|
|
|
|
}
|
2020-01-24 05:25:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-11 06:05:33 +00:00
|
|
|
// it('seeded rooms should be present in db', done => {
|
|
|
|
// knex('room').where('id', 1).orWhere('id', 2).select('name').then(roomResults => {
|
|
|
|
// if (roomResults[0].name === 'main' && roomResults[1].name === 'private') done();
|
|
|
|
// });
|
|
|
|
// });
|
2020-01-18 22:15:44 +00:00
|
|
|
|
|
|
|
it('request to api rooms should return 200', done => {
|
|
|
|
chai.request(server)
|
2020-01-18 23:42:45 +00:00
|
|
|
.get(roomEndpoint)
|
2020-01-18 22:15:44 +00:00
|
|
|
.end((err,res)=> {
|
|
|
|
if(err) done(err);
|
|
|
|
res.should.status(200);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2020-02-11 06:05:33 +00:00
|
|
|
// it('request to api rooms should return all public rooms', done => {
|
|
|
|
// chai.request(server)
|
|
|
|
// .get(roomEndpoint)
|
|
|
|
// .end((err,res)=> {
|
|
|
|
// if(err) done(err);
|
|
|
|
// res.body.should.eql(publicRooms);
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// })
|
2020-01-22 00:01:35 +00:00
|
|
|
|
2020-02-11 06:05:33 +00:00
|
|
|
// it('request to api room/1 should return 1 room record with game and message information', done => {
|
|
|
|
// chai.request(server)
|
|
|
|
// .get(`${roomEndpoint}/1`)
|
|
|
|
// .end((err,res)=> {
|
|
|
|
// if(err) done(err);
|
|
|
|
// res.body.should.eql(roomOne);
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// })
|
2020-01-18 22:15:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = apiRoomSpec;
|