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