UNPKG

@gameroom/gameroom-kit

Version:

Node kit for the Gameroom API

119 lines (117 loc) 3.09 kB
let chai = require('chai'), should = chai.should(), faker = require('faker'), { models } = require('../../'), { Adjustment, Till } = models, till_id, object; describe('Adjustment', () => { describe('setup', () => { it('should create objects for relationships', async() => { let result, error; try { result = await Till.create({ name: 'test' }); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); till_id = result.id; }); }); describe('Adjustment.create()', () => { it('should create an adjustment', async () => { let result, error; try { result = await Adjustment.create({ till_id }); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); object = result; }); }); describe('Adjustment.get()', () => { it('should get array of adjustments', async () => { let result, error; try { result = await Adjustment.get(); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('array'); }); }); describe('Adjustment.find()', () => { it('should find an adjustment', async() => { let result, error; try { result = await Adjustment.find(object, { view: 'full' }); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); object = result; }); }); describe('Adjustment keys', () => { it('should match api and kit keys', async () => { Object.keys(object).should.deep.equal(Object.keys(Adjustment.schema.attributes)); }); }); describe('Adjustment.update()', () => { it('should update a adjustment', async () => { let result, error; try { result = await Adjustment.update(object); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); }); }); describe('adjustment.save()', () => { it('should update one adjustments', 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('Adjustment.delete()', () => { it('should delete one adjustment', async () => { let result, error; try { result = await Adjustment.delete(object); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); }); }); describe('teardown', () => { it('should delete the relationship object', async() => { let result, error; try { result = await Till.delete(till_id); } catch(err) { error = err; }; should.not.exist(error); }); }); });