UNPKG

@gameroom/kit

Version:

Node kit for the Gameroom API

137 lines (132 loc) 3.45 kB
const { faker } = require('@faker-js/faker'), chai = require('chai') const { models: { Adjustment, Till } } = require('../../') const should = chai.should() let object, till_id describe('Adjustment', () => { describe('setup', () => { it('should create objects for relationships', 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') 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.getAll()', () => { it('should get array of all adjustments', async () => { let result, error try { result = await Adjustment.getAll() } 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 () => { const raw = await Adjustment.schema.adapter.find(Adjustment.schema, object.id) Object.keys(new Adjustment()).sort().should.deep.equal(Object.keys(raw).sort()) }) }) 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 error try { await Till.delete(till_id) } catch (err) { error = err } should.not.exist(error) }) }) })