Check allow-net in fetch

This commit is contained in:
Parsa Ghadimi 2018-09-05 10:59:02 +04:30 committed by Ryan Dahl
parent 1e709aa348
commit 1052f8d0c9
3 changed files with 25 additions and 6 deletions

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { testPerm, assertEqual } from "./test_util.ts";
import { test, testPerm, assert, assertEqual } from "./test_util.ts";
import * as deno from "deno";
testPerm({ net: true }, async function fetchJsonSuccess() {
@ -7,3 +7,15 @@ testPerm({ net: true }, async function fetchJsonSuccess() {
const json = await response.json();
assertEqual(json.name, "deno");
});
test(async function fetchPerm() {
let err;
try {
await fetch("http://localhost:4545/package.json");
} catch (err_) {
err = err_;
}
// TODO assert(err instanceof deno.PermissionDenied).
assert(err);
assertEqual(err.name, "deno.PermissionDenied");
});