diff options
| author | David Sherret <dsherret@users.noreply.github.com> | 2022-09-19 09:32:21 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-19 10:32:21 -0400 |
| commit | 1464b756a4ef091ef97d1bf7340188ab5fe5492a (patch) | |
| tree | 2eff346ccf5782c501460aec63a5028742066fa6 /cli/tests/testdata/run/import_meta | |
| parent | 8d50c09c0db4e9b0644263cde3f7ff990ec75259 (diff) | |
refactor: move out test files from root testdata directory into sub directories (#15949)
Diffstat (limited to 'cli/tests/testdata/run/import_meta')
| -rw-r--r-- | cli/tests/testdata/run/import_meta/importmap.json | 11 | ||||
| -rw-r--r-- | cli/tests/testdata/run/import_meta/main.out | 9 | ||||
| -rw-r--r-- | cli/tests/testdata/run/import_meta/main.ts | 34 | ||||
| -rw-r--r-- | cli/tests/testdata/run/import_meta/other.ts | 1 |
4 files changed, 55 insertions, 0 deletions
diff --git a/cli/tests/testdata/run/import_meta/importmap.json b/cli/tests/testdata/run/import_meta/importmap.json new file mode 100644 index 000000000..f8c056afd --- /dev/null +++ b/cli/tests/testdata/run/import_meta/importmap.json @@ -0,0 +1,11 @@ +{ + "imports": { + "bare": "https://example.com/", + "https://example.com/rewrite": "https://example.com/rewritten", + + "1": "https://example.com/PASS-1", + "null": "https://example.com/PASS-null", + "undefined": "https://example.com/PASS-undefined", + "[object Object]": "https://example.com/PASS-object" + } +} diff --git a/cli/tests/testdata/run/import_meta/main.out b/cli/tests/testdata/run/import_meta/main.out new file mode 100644 index 000000000..89aeddaf3 --- /dev/null +++ b/cli/tests/testdata/run/import_meta/main.out @@ -0,0 +1,9 @@ +other [WILDCARD]other.ts false +main [WILDCARD]main.ts true +Resolving ./foo.js file:///[WILDCARD]/foo.js +Resolving bare from import map https://example.com/ +Resolving https://example.com/rewrite from import map https://example.com/rewritten +Resolving without a value from import map https://example.com/PASS-undefined +Resolving 1 from import map https://example.com/PASS-1 +Resolving null from import map https://example.com/PASS-null +Resolving object from import map https://example.com/PASS-object diff --git a/cli/tests/testdata/run/import_meta/main.ts b/cli/tests/testdata/run/import_meta/main.ts new file mode 100644 index 000000000..02f0a1c58 --- /dev/null +++ b/cli/tests/testdata/run/import_meta/main.ts @@ -0,0 +1,34 @@ +import { assertThrows } from "../../../../../test_util/std/testing/asserts.ts"; + +console.log("main", import.meta.url, import.meta.main); + +import "./other.ts"; + +console.log("Resolving ./foo.js", import.meta.resolve("./foo.js")); +console.log("Resolving bare from import map", import.meta.resolve("bare")); +console.log( + "Resolving https://example.com/rewrite from import map", + import.meta.resolve("https://example.com/rewrite"), +); +console.log( + "Resolving without a value from import map", + import.meta.resolve(), +); +console.log( + "Resolving 1 from import map", + import.meta.resolve(1), +); +console.log( + "Resolving null from import map", + import.meta.resolve(null), +); +console.log( + "Resolving object from import map", + import.meta.resolve({}), +); +assertThrows(() => { + import.meta.resolve("too", "many", "arguments"); +}, TypeError); +assertThrows(() => { + import.meta.resolve("://malformed/url?asdf"); +}, TypeError); diff --git a/cli/tests/testdata/run/import_meta/other.ts b/cli/tests/testdata/run/import_meta/other.ts new file mode 100644 index 000000000..47d7527cd --- /dev/null +++ b/cli/tests/testdata/run/import_meta/other.ts @@ -0,0 +1 @@ +console.log("other", import.meta.url, import.meta.main); |
