Built motion from commit 5e31ea4.|0.0.32
[motion.git] / server / api / sugarcrm_account / index.spec.js
1 'use strict';
2
3 var proxyquire = require('proxyquire').noPreserveCache();
4
5 var sugarcrmAccountCtrlStub = {
6   index: 'sugarcrmAccountCtrl.index',
7   show: 'sugarcrmAccountCtrl.show',
8   create: 'sugarcrmAccountCtrl.create',
9   update: 'sugarcrmAccountCtrl.update',
10   destroy: 'sugarcrmAccountCtrl.destroy'
11 };
12
13 var routerStub = {
14   get: sinon.spy(),
15   put: sinon.spy(),
16   patch: sinon.spy(),
17   post: sinon.spy(),
18   delete: sinon.spy()
19 };
20
21 // require the index with our stubbed out modules
22 var sugarcrmAccountIndex = proxyquire('./index.js', {
23   'express': {
24     Router: function() {
25       return routerStub;
26     }
27   },
28   './sugarcrm_account.controller': sugarcrmAccountCtrlStub
29 });
30
31 describe('SugarcrmAccount API Router:', function() {
32
33   it('should return an express router instance', function() {
34     expect(sugarcrmAccountIndex).to.equal(routerStub);
35   });
36
37   describe('GET /api/sugarcrm/accounts', function() {
38
39     it('should route to sugarcrmAccount.controller.index', function() {
40       expect(routerStub.get
41         .withArgs('/', 'sugarcrmAccountCtrl.index')
42         ).to.have.been.calledOnce;
43     });
44
45   });
46
47   describe('GET /api/sugarcrm/accounts/:id', function() {
48
49     it('should route to sugarcrmAccount.controller.show', function() {
50       expect(routerStub.get
51         .withArgs('/:id', 'sugarcrmAccountCtrl.show')
52         ).to.have.been.calledOnce;
53     });
54
55   });
56
57   describe('POST /api/sugarcrm/accounts', function() {
58
59     it('should route to sugarcrmAccount.controller.create', function() {
60       expect(routerStub.post
61         .withArgs('/', 'sugarcrmAccountCtrl.create')
62         ).to.have.been.calledOnce;
63     });
64
65   });
66
67   describe('PUT /api/sugarcrm/accounts/:id', function() {
68
69     it('should route to sugarcrmAccount.controller.update', function() {
70       expect(routerStub.put
71         .withArgs('/:id', 'sugarcrmAccountCtrl.update')
72         ).to.have.been.calledOnce;
73     });
74
75   });
76
77   describe('PATCH /api/sugarcrm/accounts/:id', function() {
78
79     it('should route to sugarcrmAccount.controller.update', function() {
80       expect(routerStub.patch
81         .withArgs('/:id', 'sugarcrmAccountCtrl.update')
82         ).to.have.been.calledOnce;
83     });
84
85   });
86
87   describe('DELETE /api/sugarcrm/accounts/:id', function() {
88
89     it('should route to sugarcrmAccount.controller.destroy', function() {
90       expect(routerStub.delete
91         .withArgs('/:id', 'sugarcrmAccountCtrl.destroy')
92         ).to.have.been.calledOnce;
93     });
94
95   });
96
97 });