|
2 | 2 |
|
3 | 3 | // setup |
4 | 4 | import test from 'ava' |
| 5 | +import patty from './../index' |
5 | 6 |
|
6 | 7 | // test something |
7 | | -test.todo('testSomething') |
| 8 | +test('register returns resource object', async (assert) => { |
| 9 | + await assert.throws(patty.register(), Error, 'register throws with no name') |
| 10 | + let resource = await patty.register('users') |
| 11 | + assert.truthy(resource, 'resource is defined') |
| 12 | + assert.truthy(resource.hasOwnProperty('name'), 'resource has name') |
| 13 | + assert.truthy(resource.hasOwnProperty('search'), 'resource has search') |
| 14 | + assert.truthy(resource.hasOwnProperty('create'), 'resource has create') |
| 15 | + assert.truthy(resource.hasOwnProperty('read'), 'resource has read') |
| 16 | + assert.truthy(resource.hasOwnProperty('update'), 'resource has update') |
| 17 | + assert.truthy(resource.hasOwnProperty('delete'), 'resource has delete') |
| 18 | +}) |
8 | 19 |
|
9 | 20 | /* API |
10 | 21 | const pattyOpts = {port: 8081, secret: 'someSecureString', logpath: '/logs'} |
11 | 22 | const patty = require('paternity') |
12 | 23 | const handleIt = require('./some-other-resource') // same as resource obj |
13 | 24 |
|
14 | | -const someResource = await patty.register('some-resource') |
15 | | -const someOtherResource = await patty.register('some-other-resource', handleIt) |
16 | | -await patty.start(pattyOpts) |
| 25 | +async function main () { |
| 26 | + const someResource = await patty.register('some-resource') |
| 27 | + const someOtherResource = await patty.register('some-other-resource', handleIt) |
| 28 | + await patty.start(pattyOpts) |
| 29 | +} |
17 | 30 | */ |
18 | 31 |
|
19 | 32 | /* RESOURCE OBJECT |
|
0 commit comments