mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Add another basic fetch() test.
This commit is contained in:
@@ -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");
|
||||
});
|
||||
@@ -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"]);
|
||||
});
|
||||
|
||||
5
packages/fetch/tests/asset.json
Normal file
5
packages/fetch/tests/asset.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"word": "oyez",
|
||||
"times": 3,
|
||||
"where": "SCOTUS"
|
||||
}
|
||||
17
packages/fetch/tests/main.js
Normal file
17
packages/fetch/tests/main.js
Normal 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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user