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