Creazione organizza
[YouAndWeb_TwoToc] / .fr-KzWVa7 / twotoc / server / api / message / index.spec.js
diff --git a/.fr-KzWVa7/twotoc/server/api/message/index.spec.js b/.fr-KzWVa7/twotoc/server/api/message/index.spec.js
new file mode 100755 (executable)
index 0000000..61bfb40
--- /dev/null
@@ -0,0 +1,97 @@
+'use strict';
+
+var proxyquire = require('proxyquire').noPreserveCache();
+
+var messageCtrlStub = {
+  index: 'messageCtrl.index',
+  show: 'messageCtrl.show',
+  create: 'messageCtrl.create',
+  update: 'messageCtrl.update',
+  destroy: 'messageCtrl.destroy'
+};
+
+var routerStub = {
+  get: sinon.spy(),
+  put: sinon.spy(),
+  patch: sinon.spy(),
+  post: sinon.spy(),
+  delete: sinon.spy()
+};
+
+// require the index with our stubbed out modules
+var messageIndex = proxyquire('./index.js', {
+  'express': {
+    Router: function() {
+      return routerStub;
+    }
+  },
+  './message.controller': messageCtrlStub
+});
+
+describe('Message API Router:', function() {
+
+  it('should return an express router instance', function() {
+    messageIndex.should.equal(routerStub);
+  });
+
+  describe('GET /api/test', function() {
+
+    it('should route to message.controller.index', function() {
+      routerStub.get
+        .withArgs('/', 'messageCtrl.index')
+        .should.have.been.calledOnce;
+    });
+
+  });
+
+  describe('GET /api/test/:id', function() {
+
+    it('should route to message.controller.show', function() {
+      routerStub.get
+        .withArgs('/:id', 'messageCtrl.show')
+        .should.have.been.calledOnce;
+    });
+
+  });
+
+  describe('POST /api/test', function() {
+
+    it('should route to message.controller.create', function() {
+      routerStub.post
+        .withArgs('/', 'messageCtrl.create')
+        .should.have.been.calledOnce;
+    });
+
+  });
+
+  describe('PUT /api/test/:id', function() {
+
+    it('should route to message.controller.update', function() {
+      routerStub.put
+        .withArgs('/:id', 'messageCtrl.update')
+        .should.have.been.calledOnce;
+    });
+
+  });
+
+  describe('PATCH /api/test/:id', function() {
+
+    it('should route to message.controller.update', function() {
+      routerStub.patch
+        .withArgs('/:id', 'messageCtrl.update')
+        .should.have.been.calledOnce;
+    });
+
+  });
+
+  describe('DELETE /api/test/:id', function() {
+
+    it('should route to message.controller.destroy', function() {
+      routerStub.delete
+        .withArgs('/:id', 'messageCtrl.destroy')
+        .should.have.been.calledOnce;
+    });
+
+  });
+
+});