Browse Source

Messing with supertest... some things failing, some things working

Luiserebii 2 years ago
parent
commit
b73c8bdcff
Signed by: Luiserebii <luis@serebii.io> GPG Key ID: 58A745E0A5422230
3 changed files with 177 additions and 0 deletions
  1. 122
    0
      package-lock.json
  2. 3
    0
      package.json
  3. 52
    0
      test/api-v1.test.js

+ 122
- 0
package-lock.json View File

@@ -74,6 +74,12 @@
74 74
       "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz",
75 75
       "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c="
76 76
     },
77
+    "asynckit": {
78
+      "version": "0.4.0",
79
+      "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
80
+      "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
81
+      "dev": true
82
+    },
77 83
     "atob": {
78 84
       "version": "2.1.2",
79 85
       "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
@@ -338,6 +344,15 @@
338 344
       "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
339 345
       "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
340 346
     },
347
+    "combined-stream": {
348
+      "version": "1.0.7",
349
+      "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz",
350
+      "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==",
351
+      "dev": true,
352
+      "requires": {
353
+        "delayed-stream": "1.0.0"
354
+      }
355
+    },
341 356
     "component-emitter": {
342 357
       "version": "1.2.1",
343 358
       "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
@@ -376,6 +391,12 @@
376 391
       "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
377 392
       "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
378 393
     },
394
+    "cookiejar": {
395
+      "version": "2.1.2",
396
+      "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz",
397
+      "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==",
398
+      "dev": true
399
+    },
379 400
     "copy-descriptor": {
380 401
       "version": "0.1.1",
381 402
       "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz",
@@ -474,6 +495,12 @@
474 495
         }
475 496
       }
476 497
     },
498
+    "delayed-stream": {
499
+      "version": "1.0.0",
500
+      "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
501
+      "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
502
+      "dev": true
503
+    },
477 504
     "depd": {
478 505
       "version": "1.1.2",
479 506
       "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
@@ -722,6 +749,12 @@
722 749
         }
723 750
       }
724 751
     },
752
+    "extend": {
753
+      "version": "3.0.2",
754
+      "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
755
+      "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
756
+      "dev": true
757
+    },
725 758
     "extend-shallow": {
726 759
       "version": "3.0.2",
727 760
       "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz",
@@ -889,6 +922,23 @@
889 922
       "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
890 923
       "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA="
891 924
     },
925
+    "form-data": {
926
+      "version": "2.3.3",
927
+      "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
928
+      "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
929
+      "dev": true,
930
+      "requires": {
931
+        "asynckit": "0.4.0",
932
+        "combined-stream": "1.0.7",
933
+        "mime-types": "2.1.22"
934
+      }
935
+    },
936
+    "formidable": {
937
+      "version": "1.2.1",
938
+      "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz",
939
+      "integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg==",
940
+      "dev": true
941
+    },
892 942
     "forwarded": {
893 943
       "version": "0.1.2",
894 944
       "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
@@ -1713,6 +1763,12 @@
1713 1763
       "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz",
1714 1764
       "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs="
1715 1765
     },
1766
+    "process-nextick-args": {
1767
+      "version": "2.0.0",
1768
+      "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
1769
+      "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
1770
+      "dev": true
1771
+    },
1716 1772
     "proxy-addr": {
1717 1773
       "version": "2.0.4",
1718 1774
       "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz",
@@ -2135,6 +2191,66 @@
2135 2191
       "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz",
2136 2192
       "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E="
2137 2193
     },
2194
+    "superagent": {
2195
+      "version": "3.8.3",
2196
+      "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.3.tgz",
2197
+      "integrity": "sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA==",
2198
+      "dev": true,
2199
+      "requires": {
2200
+        "component-emitter": "1.2.1",
2201
+        "cookiejar": "2.1.2",
2202
+        "debug": "3.2.6",
2203
+        "extend": "3.0.2",
2204
+        "form-data": "2.3.3",
2205
+        "formidable": "1.2.1",
2206
+        "methods": "1.1.2",
2207
+        "mime": "1.4.1",
2208
+        "qs": "6.5.2",
2209
+        "readable-stream": "2.3.6"
2210
+      },
2211
+      "dependencies": {
2212
+        "isarray": {
2213
+          "version": "1.0.0",
2214
+          "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
2215
+          "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
2216
+          "dev": true
2217
+        },
2218
+        "readable-stream": {
2219
+          "version": "2.3.6",
2220
+          "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
2221
+          "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
2222
+          "dev": true,
2223
+          "requires": {
2224
+            "core-util-is": "1.0.2",
2225
+            "inherits": "2.0.3",
2226
+            "isarray": "1.0.0",
2227
+            "process-nextick-args": "2.0.0",
2228
+            "safe-buffer": "5.1.2",
2229
+            "string_decoder": "1.1.1",
2230
+            "util-deprecate": "1.0.2"
2231
+          }
2232
+        },
2233
+        "string_decoder": {
2234
+          "version": "1.1.1",
2235
+          "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
2236
+          "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
2237
+          "dev": true,
2238
+          "requires": {
2239
+            "safe-buffer": "5.1.2"
2240
+          }
2241
+        }
2242
+      }
2243
+    },
2244
+    "supertest": {
2245
+      "version": "3.4.2",
2246
+      "resolved": "https://registry.npmjs.org/supertest/-/supertest-3.4.2.tgz",
2247
+      "integrity": "sha512-WZWbwceHUo2P36RoEIdXvmqfs47idNNZjCuJOqDz6rvtkk8ym56aU5oglORCpPeXGxT7l9rkJ41+O1lffQXYSA==",
2248
+      "dev": true,
2249
+      "requires": {
2250
+        "methods": "1.1.2",
2251
+        "superagent": "3.8.3"
2252
+      }
2253
+    },
2138 2254
     "supports-color": {
2139 2255
       "version": "6.0.0",
2140 2256
       "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz",
@@ -2283,6 +2399,12 @@
2283 2399
       "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz",
2284 2400
       "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ=="
2285 2401
     },
2402
+    "util-deprecate": {
2403
+      "version": "1.0.2",
2404
+      "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
2405
+      "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
2406
+      "dev": true
2407
+    },
2286 2408
     "utils-merge": {
2287 2409
       "version": "1.0.1",
2288 2410
       "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",

+ 3
- 0
package.json View File

@@ -18,5 +18,8 @@
18 18
     "express": "^4.16.4",
19 19
     "jshint": "^2.10.1",
20 20
     "mocha": "^6.0.1"
21
+  },
22
+  "devDependencies": {
23
+    "supertest": "^3.4.2"
21 24
   }
22 25
 }

+ 52
- 0
test/api-v1.test.js View File

@@ -0,0 +1,52 @@
1
+const MathFun = require("../src/math");
2
+
3
+const chai = require("chai");
4
+const expect = chai.expect;
5
+
6
+const supertest = require("supertest");
7
+const app = require("../app");
8
+
9
+/*
10
+ * Our API server test file using supertest!
11
+ *    npm: https://www.npmjs.com/package/supertest
12
+ *    syntax docs: https://visionmedia.github.io/superagent/ (syntax is all based on superagent)
13
+ *
14
+ */
15
+
16
+
17
+describe("API V1", function(){
18
+   
19
+   it("fibonacci endpoint returns valid fib", function(done){
20
+
21
+      //Pass 10, expecting 34 and status code 200
22
+      supertest(app)
23
+         .get("/v1/fibonacci")
24
+         .query({ n: 10 })
25
+         .expect(200)
26
+         .end(function(err, res){
27
+            if (err) return done(err);
28
+            let json = JSON.stringify(res.body);
29
+            console.log(json);
30
+            expect(json.result).to.equal(34);
31
+            done();
32
+         });
33
+
34
+   });
35
+
36
+/*   it("isfib returns valid response", function(){
37
+
38
+   });
39
+
40
+   it("failure on no 'n' passed", function(){
41
+
42
+   });
43
+
44
+   it("returns apology on nothing hit", function(){
45
+
46
+   });
47
+  */ 
48
+   
49
+});
50
+
51
+
52
+

Loading…
Cancel
Save