UNPKG

@gameroom/gameroom-kit

Version:

Node kit for the Gameroom API

94 lines (92 loc) 2.32 kB
let chai = require('chai'), should = chai.should(), faker = require('faker'), { models } = require('../../'), { Till } = models, object; describe('Till', () => { describe('Till.create()', () => { it('should create an till', async () => { let result, error; try { result = await Till.create({ name: faker.random.word() }); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); object = result; }); }); describe('Till.get()', () => { it('should get array of tills', async () => { let result, error; try { result = await Till.get(); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('array'); }); }); describe('Till.find()', () => { it('should find a till', async() => { let result, error; try { result = await Till.find(object, { view: 'full' }); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); object = result; }); }); describe('Till keys', () => { it('should match api and kit keys', async () => { Object.keys(object).should.deep.equal(Object.keys(Till.schema.attributes)); }); }); describe('Till.update()', () => { it('should update a till', async () => { let result, error; try { result = await Till.update(object); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); }); }); describe('till.save()', () => { it('should update one till', 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('Till.delete()', () => { it('should delete one till', async () => { let result, error; try { result = await Till.delete(object); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); }); }); });