UNPKG

@gameroom/kit

Version:

Node kit for the Gameroom API

112 lines (107 loc) 2.65 kB
const { faker } = require('@faker-js/faker'), chai = require('chai') const { models: { Tax } } = require('../../') const should = chai.should() let object describe('Tax', () => { describe('Tax.create()', () => { it('should create an tax', async () => { let result, error try { result = await Tax.create({ name: faker.random.word() }) } catch (err) { error = err } should.not.exist(error) should.exist(result) result.should.be.a('object') object = result }) }) describe('Tax.get()', () => { it('should get array of taxes', async () => { let result, error try { result = await Tax.get() } catch (err) { error = err } should.not.exist(error) should.exist(result) result.should.be.a('array') }) }) describe('Tax.getAll()', () => { it('should get array of all taxes', async () => { let result, error try { result = await Tax.getAll() } catch (err) { error = err } should.not.exist(error) should.exist(result) result.should.be.a('array') }) }) describe('Tax.find()', () => { it('should find a tax', async () => { let result, error try { result = await Tax.find(object, { view: 'full' }) } catch (err) { error = err } should.not.exist(error) should.exist(result) result.should.be.a('object') object = result }) }) describe('Tax keys', () => { it('should match api and kit keys', async () => { const raw = await Tax.schema.adapter.find(Tax.schema, object.id) Object.keys(new Tax()).sort().should.deep.equal(Object.keys(raw).sort()) }) }) describe('Tax.update()', () => { it('should update a tax', async () => { let result, error try { result = await Tax.update(object) } catch (err) { error = err } should.not.exist(error) should.exist(result) result.should.be.a('object') }) }) describe('tax.save()', () => { it('should update one tax', 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('Tax.delete()', () => { it('should delete one tax', async () => { let result, error try { result = await Tax.delete(object) } catch (err) { error = err } should.not.exist(error) should.exist(result) }) }) })