UNPKG

@gameroom/kit

Version:

Node kit for the Gameroom API

112 lines (107 loc) 2.68 kB
const { faker } = require('@faker-js/faker'), chai = require('chai') const { models: { Till } } = require('../../') const should = chai.should() let 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.getAll()', () => { it('should get array of all tills', async () => { let result, error try { result = await Till.getAll() } 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 () => { const raw = await Till.schema.adapter.find(Till.schema, object.id) Object.keys(new Till()).sort().should.deep.equal(Object.keys(raw).sort()) }) }) 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) }) }) })