|
1 | 1 | const commtrackr = require('./index.js'); |
2 | 2 |
|
3 | | -async function commTrackrHandler(data) { |
| 3 | +async function createHandler(data) { |
| 4 | + return data; |
| 5 | +}; |
| 6 | + |
| 7 | +async function updateHandler(req, data) { |
| 8 | + return data; |
| 9 | +}; |
| 10 | + |
| 11 | +async function syncHandler(req, data) { |
4 | 12 | return data; |
5 | 13 | }; |
6 | 14 |
|
@@ -55,12 +63,24 @@ describe('CommTrackr Backend Initialization', () => { |
55 | 63 | required: true |
56 | 64 | } |
57 | 65 | ]), |
58 | | - handler: commTrackrHandler, |
| 66 | + handlers: { |
| 67 | + create: createHandler, |
| 68 | + update: updateHandler, |
| 69 | + sync: syncHandler |
| 70 | + } |
59 | 71 | })).not.toThrow(); |
60 | 72 | }); |
61 | | - test('handler', async () => { |
62 | | - expect(typeof commTrackrHandler).toBe('function'); |
63 | | - const result = await commTrackrHandler({ test: 'data' }); |
| 73 | + test('handlers', async () => { |
| 74 | + expect(typeof createHandler).toBe('function'); |
| 75 | + var result = await createHandler({ test: 'data' }); |
| 76 | + expect(typeof result).toBe('object'); |
| 77 | + expect(result).toHaveProperty('test', 'data'); |
| 78 | + expect(typeof updateHandler).toBe('function'); |
| 79 | + result = await updateHandler({}, { test: 'data' }); |
| 80 | + expect(typeof result).toBe('object'); |
| 81 | + expect(result).toHaveProperty('test', 'data'); |
| 82 | + expect(typeof syncHandler).toBe('function'); |
| 83 | + result = await syncHandler({}, { test: 'data' }); |
64 | 84 | expect(typeof result).toBe('object'); |
65 | 85 | expect(result).toHaveProperty('test', 'data'); |
66 | 86 | }); |
|
0 commit comments