@@ -7,50 +7,35 @@ import assert from 'assert';
77import server from './test-app' ;
88import memory from '../src' ;
99
10- const _ids = { } ;
11- const app = feathers ( ) . use ( '/people' , memory ( ) ) ;
12- const people = app . service ( 'people' ) ;
13-
14- function clean ( ) {
15- people . _uId = 0 ;
16- people . store = { } ;
17- }
18-
1910describe ( 'Feathers Memory Service' , ( ) => {
20- before ( clean ) ;
21- after ( clean ) ;
22-
23- beforeEach ( done => {
24- people . create ( {
25- name : 'Doug' ,
26- age : 32
27- } ) . then ( data => {
28- _ids . Doug = data . id ;
29- done ( ) ;
30- } , done ) ;
31- } ) ;
32-
33- afterEach ( done => {
34- const doneNow = ( ) => done ( ) ;
35- people . remove ( _ids . Doug ) . then ( doneNow , doneNow ) ;
36- } ) ;
37-
38- it ( 'is CommonJS compatible' , ( ) => {
39- assert . equal ( typeof require ( '../lib' ) , 'function' ) ;
40- } ) ;
41-
42- it ( 'update with string id works' , done => {
43- people . create ( {
11+ const events = [ 'testing' ] ;
12+ const app = feathers ( )
13+ . use ( '/people' , memory ( { events } ) )
14+ . use ( '/people-customid' , memory ( {
15+ id : 'customid' , events
16+ } ) ) ;
17+
18+ it ( 'is CommonJS compatible' , ( ) =>
19+ assert . equal ( typeof require ( '../lib' ) , 'function' )
20+ ) ;
21+
22+ it ( 'update with string id works' , ( ) =>
23+ app . service ( 'people' ) . create ( {
4424 name : 'Tester' ,
4525 age : 33
4626 } ) . then ( person =>
47- people . update ( person . id . toString ( ) , person ) . then ( updatedPerson =>
48- assert . equal ( typeof updatedPerson . id , 'number' )
49- ) . then ( ( ) => people . remove ( person . id . toString ( ) ) )
50- ) . then ( ( ) => done ( ) ) . catch ( done ) ;
51- } ) ;
52-
53- base ( people , _ids , errors ) ;
27+ app . service ( 'people' )
28+ . update ( person . id . toString ( ) , person )
29+ . then ( updatedPerson =>
30+ assert . equal ( typeof updatedPerson . id , 'number' )
31+ )
32+ . then ( ( ) => app . service ( 'people' )
33+ . remove ( person . id . toString ( ) ) )
34+ )
35+ ) ;
36+
37+ base ( app , errors ) ;
38+ base ( app , errors , 'people-customid' , 'customid' ) ;
5439} ) ;
5540
5641describe ( 'Memory service example test' , ( ) => {
0 commit comments