UNPKG

@gameroom/kit

Version:

Node kit for the Gameroom API

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