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