mirror of
https://github.com/typicode/json-server.git
synced 2025-07-28 20:52:08 +08:00

* Remove automatic type conversion * Remove body-parser from default middlewares * Ignore lib * ES2015 * Use shortid * Add babel-register * Update paths to ./lib * Add .npmignore * Update bin * temp fix * Fix bin * Add message when creating default db * Use fs.watch * Fix operator existence test * Fix 0.12 tests * Update dependencies * Update * Increase timeout * Fix 0.12 support * 0.9.0-beta.1 * Fix missing example.json issue * 0.9.0-beta.2 * Update message * Update CHANGELOG.md * Update lowdb dependency * Add error message * Update README.md * Add database validation * Update * Update * Fix tests * Update
25 lines
545 B
JavaScript
25 lines
545 B
JavaScript
const assert = require('assert')
|
|
const validateData = require('../../src/server/router/validate-data')
|
|
|
|
describe('validateData', () => {
|
|
it('should throw an error if data contains /', () => {
|
|
assert.throws(
|
|
() => validateData({ 'a/b': [] }),
|
|
/found \//
|
|
)
|
|
})
|
|
|
|
it('should throw an error if data is an array', () => {
|
|
assert.throws(
|
|
() => validateData([]),
|
|
/must be an object/
|
|
)
|
|
})
|
|
|
|
it('shouldn\'t throw an error', () => {
|
|
assert.doesNotThrow(
|
|
() => validateData({ a: [] })
|
|
)
|
|
})
|
|
})
|