@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('../../'),
{ Tax } = models,
object;
describe('Tax', () => {
describe('Tax.create()', () => {
it('should create an tax', async () => {
let result, error;
try {
result = await Tax.create({ name: faker.random.word() });
} catch(err) {
error = err;
};
should.not.exist(error);
should.exist(result);
result.should.be.a('object');
object = result;
});
});
describe('Tax.get()', () => {
it('should get array of taxes', async () => {
let result, error;
try {
result = await Tax.get();
} catch(err) {
error = err;
};
should.not.exist(error);
should.exist(result);
result.should.be.a('array');
});
});
describe('Tax.find()', () => {
it('should find a tax', async() => {
let result, error;
try {
result = await Tax.find(object, { view: 'full' });
} catch(err) {
error = err;
};
should.not.exist(error);
should.exist(result);
result.should.be.a('object');
object = result;
});
});
describe('Tax keys', () => {
it('should match api and kit keys', async () => {
Object.keys(object).should.deep.equal(Object.keys(Tax.schema.attributes));
});
});
describe('Tax.update()', () => {
it('should update a tax', async () => {
let result, error;
try {
result = await Tax.update(object);
} catch(err) {
error = err;
};
should.not.exist(error);
should.exist(result);
result.should.be.a('object');
});
});
describe('tax.save()', () => {
it('should update one tax', 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('Tax.delete()', () => {
it('should delete one tax', async () => {
let result, error;
try {
result = await Tax.delete(object);
} catch(err) {
error = err;
};
should.not.exist(error);
should.exist(result);
});
});
});