Просмотр исходного кода

Update unit tests to include misc testing and debug output

Matt Coles лет назад: 9
Родитель
Сommit
52bfa42c27
4 измененных файлов с 33 добавлено и 3 удалено
  1. 1 0
      .gitignore
  2. 3 3
      package.json
  3. 22 0
      spec/misc-ops-spec.js
  4. 7 0
      spec/support/jasmine.json

+ 1 - 0
.gitignore

1
 node_modules/
1
 node_modules/
2
+debug.log
2
 logpasswd
3
 logpasswd
3
 log/
4
 log/
4
 ssl/
5
 ssl/

+ 3 - 3
package.json

4
   "description": "Server for the IP project",
4
   "description": "Server for the IP project",
5
   "main": "index.js",
5
   "main": "index.js",
6
   "scripts": {
6
   "scripts": {
7
-    "pretest": "node index.js &",
8
-    "test": "sleep 2; jasmine-node --verbose --captureExceptions spec; node utils/flushdb.js",
7
+    "pretest": "node index.js > debug.log &",
8
+    "test": "sleep 2; jasmine; node utils/flushdb.js",
9
     "posttest": "killall node"
9
     "posttest": "killall node"
10
   },
10
   },
11
   "repository": {
11
   "repository": {
28
     "serve-index": "^1.7.3"
28
     "serve-index": "^1.7.3"
29
   },
29
   },
30
   "devDependencies": {
30
   "devDependencies": {
31
-    "jasmine-node": "^1.14.5"
31
+    "jasmine": "^2.4.1"
32
   }
32
   }
33
 }
33
 }

+ 22 - 0
spec/misc-ops-spec.js

1
+var request = require("request");
2
+var base_url = "http://localhost:3000";
3
+
4
+describe("Misc Operations", function () {
5
+  describe("GET /hello/:name", function () {
6
+    it("says hello world when no :name present", function (done) {
7
+      request(base_url + "/hello/", function (error, response, body) {
8
+        expect(response.statusCode).toBe(200);
9
+        expect(body).toBe("<title>Hello World!</title>Hello World!");
10
+        done();
11
+      })
12
+    });
13
+
14
+    it("says hello to the name provided", function (done) {
15
+      request(base_url + "/hello/Matt/", function (error, response, body) {
16
+        expect(response.statusCode).toBe(200);
17
+        expect(body).toBe("<title>Hello Matt!</title>Hello Matt!");
18
+        done();
19
+      });
20
+    })
21
+  });
22
+});

+ 7 - 0
spec/support/jasmine.json

1
+{
2
+    "spec_dir": "spec",
3
+    "spec_files": [
4
+        "misc-ops-spec.js",
5
+        "user-ops-spec.js"
6
+    ]
7
+}