UNPKG

@gameroom/gameroom-kit

Version:

Node kit for the Gameroom API

97 lines (95 loc) 2.53 kB
let chai = require('chai'), should = chai.should(), faker = require('faker'), { models } = require('../../'), { Customer } = models, object; describe('Customer', () => { describe('Customer.create()', () => { it('should create a customer', async () => { let result, error; try { result = await Customer.create({ password: 'password' }); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); object = result; }); }); describe('Customer.get()', () => { it('should get array of customers', async () => { let result, error; try { result = await Customer.get(); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('array'); }); }); describe('Customer.find()', () => { it('should find a customer', async() => { let result, error; try { result = await Customer.find(object, { view: 'full' }); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); object = result; }); }); describe('Customer keys', () => { it('should match api and kit keys', async () => { object.password = 'password'; const objectKeys = Object.keys(object).sort(); const attributeKeys = Object.keys(Customer.schema.attributes).sort(); objectKeys.should.deep.equal(attributeKeys); }); }); describe('Customer.update()', () => { it('should update a customer', async () => { let result, error; try { result = await Customer.update(object); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); result.should.be.a('object'); }); }); describe('customer.save()', () => { it('should update one customers', 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('Customer.delete()', () => { it('should delete one customer', async () => { let result, error; try { result = await Customer.delete(object); } catch(err) { error = err; }; should.not.exist(error); should.exist(result); }); }); });