@gameroom/gameroom-kit
Version:
Node kit for the Gameroom API
96 lines (94 loc) • 2.36 kB
JavaScript
let chai = require('chai'),
should = chai.should(),
faker = require('faker'),
{ models } = require('../../'),
{ Store } = models,
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.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 () => {
Object.keys(object).should.deep.equal(Object.keys(Store.schema.attributes));
});
});
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);
});
});
});