@gameroom/gameroom-kit
Version:
Node kit for the Gameroom API
95 lines (93 loc) • 2.53 kB
JavaScript
let chai = require('chai'),
should = chai.should(),
faker = require('faker'),
{ models } = require('../../'),
{ Option_Group } = models,
object;
describe('Option_Group', () => {
describe('Option_Group.create()', () => {
it('should create an option_group', async () => {
let result, error;
try {
result = await Option_Group.create({ name: faker.random.word() });
} catch(err) {
error = err;
};
should.not.exist(error);
should.exist(result);
result.should.be.a('object');
object = result;
});
});
describe('Option_Group.get()', () => {
it('should get array of option_groups', async () => {
let result, error;
try {
result = await Option_Group.get();
} catch(err) {
error = err;
};
should.not.exist(error);
should.exist(result);
result.should.be.a('array');
});
});
describe('Option_Group.find()', () => {
it('should find an option_group', async() => {
let result, error;
try {
result = await Option_Group.find(object, { view: 'full' });
} catch(err) {
error = err;
};
should.not.exist(error);
should.exist(result);
result.should.be.a('object');
object = result;
});
});
describe('Option_Group keys', () => {
it('should match api and kit keys', async () => {
Object.keys(object).should.deep.equal(Object.keys(Option_Group.schema.attributes));
});
});
describe('Option_Group.update()', () => {
it('should update a option_group', async () => {
let result, error;
object.name = faker.random.word();
try {
result = await Option_Group.update(object);
} catch(err) {
error = err;
};
should.not.exist(error);
should.exist(result);
result.should.be.a('object');
});
});
describe('option_group.save()', () => {
it('should update one option_group', 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('Option_Group.delete()', () => {
it('should delete one option_group', async () => {
let result, error;
try {
result = await Option_Group.delete(object);
} catch(err) {
error = err;
};
should.not.exist(error);
should.exist(result);
});
});
});