Files: c4f0656414375ade1e3c819a7b61d5808010551c / tests / isBook.js
762 bytesRaw
1 | const test = require('tape') |
2 | const validator = require('is-my-json-valid') |
3 | |
4 | const isBook = require('../isBook.js') |
5 | |
6 | test('isBoot / book schema', t => { |
7 | |
8 | const simpleBook = { |
9 | type: 'bookclub', |
10 | authors: 'Ursula le Guin', |
11 | title: 'The Dispossessed' |
12 | } |
13 | t.ok(isBook(simpleBook), 'validates simple book') |
14 | |
15 | const incompleteBook = { |
16 | type: 'bookclub', |
17 | authors: 'Ursula le Guin', |
18 | } |
19 | t.notOk(isBook(incompleteBook), 'invalidates incompleteBook book') |
20 | t.equal(isBook.errors[0].message, 'is required', 'provides error messages') |
21 | |
22 | const multiAuthorBook = { |
23 | type: 'bookclub', |
24 | authors: ['Ursula le Guin', 'Terry Pratchett'], |
25 | title: 'The Dispossessed' |
26 | } |
27 | t.ok(isBook(multiAuthorBook), 'validates multi-author book') |
28 | |
29 | t.end() |
30 | }) |
31 | |
32 |
Built with git-ssb-web