UNPKG

@gameroom/gameroom-kit

Version:

Node kit for the Gameroom API

94 lines (92 loc) 2.33 kB
let chai = require('chai'), should = chai.should(), faker = require('faker'), { models } = require('../../'), { Note } = models, object; describe('Note', () => { describe('Note.create()', () => { it('should create an note', async () => { let result, error; try { result = await Note.create({ info: faker.random.words() }); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); object = result; }); }); describe('Note.get()', () => { it('should get array of notes', async () => { let result, error; try { result = await Note.get(); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('array'); }); }); describe('Note.find()', () => { it('should find a note', async() => { let result, error; try { result = await Note.find(object, { view: 'full' }); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); object = result; }); }); describe('Note keys', () => { it('should match api and kit keys', async () => { Object.keys(object).should.deep.equal(Object.keys(Note.schema.attributes)); }); }); describe('Note.update()', () => { it('should update a note', async () => { let result, error; try { result = await Note.update(object); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); }); }); describe('note.save()', () => { it('should update one notes', async () => { let result, error; try { result = await object.save(); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); }); }); describe('Note.delete()', () => { it('should delete one note', async () => { let result, error; try { result = await Note.delete(object); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); }); }); });