UNPKG

@gameroom/kit

Version:

Node kit for the Gameroom API

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