Add another basic fetch() test.

This commit is contained in:
Ben Newman
2018-06-28 18:47:36 -04:00
parent a20f4e74d8
commit 9abd2ce4c8
4 changed files with 24 additions and 9 deletions

View File

@@ -1,8 +0,0 @@
// Import Tinytest from the tinytest Meteor package.
import { Tinytest } from "meteor/tinytest";
// Write your tests here!
// Here is an example.
Tinytest.add('fetch - example', function (test) {
test.equal(typeof fetch, "function");
});

View File

@@ -28,5 +28,6 @@ Package.onTest(function(api) {
api.use("ecmascript");
api.use("tinytest");
api.use("fetch");
api.mainModule("fetch-tests.js");
api.mainModule("tests/main.js");
api.addAssets("tests/asset.json", ["client", "server"]);
});

View File

@@ -0,0 +1,5 @@
{
"word": "oyez",
"times": 3,
"where": "SCOTUS"
}

View File

@@ -0,0 +1,17 @@
import { Tinytest } from "meteor/tinytest";
Tinytest.add("fetch - sanity", function (test) {
test.equal(typeof fetch, "function");
});
Tinytest.addAsync("fetch - asset", function (test) {
return fetch(
Meteor.absoluteUrl("/packages/local-test_fetch/tests/asset.json")
).then(res => {
if (! res.ok) throw res;
return res.json();
}).then(json => {
test.equal(json.word, "oyez");
test.equal(json.times, 3);
});
});