Ver código fonte

Add unit test for /society/leave/

Matt Coles 9 anos atrás
pai
commit
cc9a66a3ac
1 arquivos alterados com 49 adições e 0 exclusões
  1. 49 0
      spec/society-ops-spec.js

+ 49 - 0
spec/society-ops-spec.js

@@ -244,4 +244,53 @@ describe("Society Operations", function () {
244 244
     });
245 245
   }); //end POST /society/join/
246 246
 
247
+  describe("POST /society/leave/", function() {
248
+    it("correctly leaves the society", function (done) {
249
+      request({
250
+        url: base_url + "/society/leave/",
251
+        method: "POST",
252
+        json: {
253
+          society: "foo123soc",
254
+          auth: foo456auth
255
+        }
256
+      }, function (error, response, body) {
257
+        expect(response.statusCode).toBe(200);
258
+        expect(body.success).toBe(1);
259
+        expect(body.error).toBe(0);
260
+        done();
261
+      });
262
+    });
263
+
264
+    it("does not leave the society twice", function (done) {
265
+      request({
266
+        url: base_url + "/society/leave/",
267
+        method: "POST",
268
+        json: {
269
+          society: "foo123soc",
270
+          auth: foo456auth
271
+        }
272
+      }, function (error, response, body) {
273
+        expect(response.statusCode).toBe(200);
274
+        expect(body.success).toBe(0);
275
+        expect(body.error).toBe(1);
276
+        done();
277
+      });
278
+    });
279
+
280
+    it("rejects malformed requests", function (done) {
281
+      request({
282
+        url: base_url + "/society/leave/",
283
+        method: "POST",
284
+        json: {
285
+          society: "foo123soc",
286
+        }
287
+      }, function (error, response, body) {
288
+        expect(response.statusCode).toBe(200);
289
+        expect(body.success).toBe(0);
290
+        expect(body.error).toBe(2);
291
+        done();
292
+      });
293
+    });
294
+  }); //end POST /society/leave/
295
+
247 296
 });