@gameroom/kit
Version:
Node kit for the Gameroom API
113 lines (108 loc) • 2.92 kB
JavaScript
const { faker } = require('@faker-js/faker'),
chai = require('chai')
const {
models: { Option_Group }
} = require('../../')
const should = chai.should()
let 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.getAll()', () => {
it('should get array of all option_groups', async () => {
let result, error
try {
result = await Option_Group.getAll()
} 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 () => {
const raw = await Option_Group.schema.adapter.find(Option_Group.schema, object.id)
Object.keys(new Option_Group()).sort().should.deep.equal(Object.keys(raw).sort())
})
})
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)
})
})
})