UNPKG

@gameroom/kit

Version:

Node kit for the Gameroom API

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