@gameroom/kit
Version:
Node kit for the Gameroom API
111 lines (106 loc) • 2.73 kB
JavaScript
const chai = require('chai')
const {
models: { Customer }
} = require('../../')
const should = chai.should()
let object
describe('Customer', () => {
describe('Customer.create()', () => {
it('should create a customer', async () => {
let result, error
try {
result = await Customer.create({ password: 'password' })
} catch (err) {
error = err
}
should.not.exist(error)
should.exist(result)
result.should.be.a('object')
object = result
})
})
describe('Customer.get()', () => {
it('should get array of customers', async () => {
let result, error
try {
result = await Customer.get()
} catch (err) {
error = err
}
should.not.exist(error)
should.exist(result)
result.should.be.a('array')
})
})
describe('Customer.getAll()', () => {
it('should get array of all customers', async () => {
let result, error
try {
result = await Customer.getAll()
} catch (err) {
error = err
}
should.not.exist(error)
should.exist(result)
result.should.be.a('array')
})
})
describe('Customer.find()', () => {
it('should find a customer', async () => {
let result, error
try {
result = await Customer.find(object, { view: 'full' })
} catch (err) {
error = err
}
should.not.exist(error)
should.exist(result)
result.should.be.a('object')
object = result
})
})
describe('Customer keys', () => {
it('should match api and kit keys', async () => {
const raw = await Customer.schema.adapter.find(Customer.schema, object.id)
Object.keys(new Customer()).sort().should.deep.equal(Object.keys(raw).sort())
})
})
describe('Customer.update()', () => {
it('should update a customer', async () => {
let result, error
try {
result = await Customer.update(object)
} catch (err) {
error = err
}
should.not.exist(error)
should.exist(result)
result.should.be.a('object')
})
})
describe('customer.save()', () => {
it('should update one customers', 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('Customer.delete()', () => {
it('should delete one customer', async () => {
let result, error
try {
result = await Customer.delete(object)
} catch (err) {
error = err
}
should.not.exist(error)
should.exist(result)
})
})
})