Files
json-server/test/server/validate-data.js
typicode 2b26630ac6 v0.9.0 (#404)
* 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
2016-11-12 01:59:43 +01:00

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: [] })
)
})
})