summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/bundle
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-09-19 09:32:21 -0500
committerGitHub <noreply@github.com>2022-09-19 10:32:21 -0400
commit1464b756a4ef091ef97d1bf7340188ab5fe5492a (patch)
tree2eff346ccf5782c501460aec63a5028742066fa6 /cli/tests/testdata/bundle
parent8d50c09c0db4e9b0644263cde3f7ff990ec75259 (diff)
refactor: move out test files from root testdata directory into sub directories (#15949)
Diffstat (limited to 'cli/tests/testdata/bundle')
-rw-r--r--cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts1
-rw-r--r--cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts.out2
-rw-r--r--cli/tests/testdata/bundle/bundle.test.out27
-rw-r--r--cli/tests/testdata/bundle/check_local_by_default/no_errors.out (renamed from cli/tests/testdata/bundle/check_local_by_default.out)0
-rw-r--r--cli/tests/testdata/bundle/check_local_by_default/no_errors.ts (renamed from cli/tests/testdata/bundle/check_local_by_default.ts)0
-rw-r--r--cli/tests/testdata/bundle/check_local_by_default/type_error.out (renamed from cli/tests/testdata/bundle/check_local_by_default2.out)2
-rw-r--r--cli/tests/testdata/bundle/check_local_by_default/type_error.ts (renamed from cli/tests/testdata/bundle/check_local_by_default2.ts)0
-rw-r--r--cli/tests/testdata/bundle/decorators/ts_decorators.out49
-rw-r--r--cli/tests/testdata/bundle/decorators/ts_decorators.ts25
-rw-r--r--cli/tests/testdata/bundle/dynamic_import.ts3
-rw-r--r--cli/tests/testdata/bundle/ignore_directives.test.out6
-rw-r--r--cli/tests/testdata/bundle/import_map/import_map.json5
-rw-r--r--cli/tests/testdata/bundle/import_map/main.ts17
-rw-r--r--cli/tests/testdata/bundle/jsx.out9
-rw-r--r--cli/tests/testdata/bundle/lockfile/check_error.json5
-rw-r--r--cli/tests/testdata/bundle/lockfile/check_error.out4
16 files changed, 154 insertions, 1 deletions
diff --git a/cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts b/cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts
new file mode 100644
index 000000000..c0748305d
--- /dev/null
+++ b/cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts
@@ -0,0 +1 @@
+import "foo";
diff --git a/cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts.out b/cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts.out
new file mode 100644
index 000000000..44d063a5e
--- /dev/null
+++ b/cli/tests/testdata/bundle/bare_imports/error_with_bare_import.ts.out
@@ -0,0 +1,2 @@
+[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../
+ at file:///[WILDCARD]/error_with_bare_import.ts:[WILDCARD]
diff --git a/cli/tests/testdata/bundle/bundle.test.out b/cli/tests/testdata/bundle/bundle.test.out
new file mode 100644
index 000000000..6b1c109d3
--- /dev/null
+++ b/cli/tests/testdata/bundle/bundle.test.out
@@ -0,0 +1,27 @@
+[WILDCARD]
+function printHello() {
+ console.log("Hello");
+}
+function returnsFoo() {
+ return "Foo";
+}
+function printHello2() {
+ printHello();
+}
+function returnsHi() {
+ return "Hi";
+}
+function returnsFoo2() {
+ return returnsFoo();
+}
+function printHello3() {
+ printHello2();
+}
+function throwsError() {
+ throw Error("exception from mod1");
+}
+export { returnsHi as returnsHi };
+export { returnsFoo2 as returnsFoo2 };
+export { printHello3 as printHello3 };
+export { throwsError as throwsError };
+
diff --git a/cli/tests/testdata/bundle/check_local_by_default.out b/cli/tests/testdata/bundle/check_local_by_default/no_errors.out
index c4559d1fa..c4559d1fa 100644
--- a/cli/tests/testdata/bundle/check_local_by_default.out
+++ b/cli/tests/testdata/bundle/check_local_by_default/no_errors.out
diff --git a/cli/tests/testdata/bundle/check_local_by_default.ts b/cli/tests/testdata/bundle/check_local_by_default/no_errors.ts
index 2ae8c2692..2ae8c2692 100644
--- a/cli/tests/testdata/bundle/check_local_by_default.ts
+++ b/cli/tests/testdata/bundle/check_local_by_default/no_errors.ts
diff --git a/cli/tests/testdata/bundle/check_local_by_default2.out b/cli/tests/testdata/bundle/check_local_by_default/type_error.out
index 60f5760f8..6d53e9498 100644
--- a/cli/tests/testdata/bundle/check_local_by_default2.out
+++ b/cli/tests/testdata/bundle/check_local_by_default/type_error.out
@@ -1,4 +1,4 @@
error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'.
const b: "b" = 12;
^
- at [WILDCARD]bundle/check_local_by_default2.ts:3:7
+ at [WILDCARD]bundle/check_local_by_default/type_error.ts:3:7
diff --git a/cli/tests/testdata/bundle/check_local_by_default2.ts b/cli/tests/testdata/bundle/check_local_by_default/type_error.ts
index 5177ff944..5177ff944 100644
--- a/cli/tests/testdata/bundle/check_local_by_default2.ts
+++ b/cli/tests/testdata/bundle/check_local_by_default/type_error.ts
diff --git a/cli/tests/testdata/bundle/decorators/ts_decorators.out b/cli/tests/testdata/bundle/decorators/ts_decorators.out
new file mode 100644
index 000000000..2f503fdd0
--- /dev/null
+++ b/cli/tests/testdata/bundle/decorators/ts_decorators.out
@@ -0,0 +1,49 @@
+[WILDCARD]
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+// This code was bundled using `deno bundle` and it's not recommended to edit it manually
+
+var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+function a() {
+ console.log("a(): evaluated");
+ return (_target, _propertyKey, _descriptor)=>{
+ console.log("a(): called");
+ };
+}
+class B {
+ method() {
+ console.log("method");
+ }
+}
+__decorate([
+ a()
+], B.prototype, "method", null);
+var __decorate1 = this && this.__decorate || function(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+};
+function Decorator() {
+ return function(target, propertyKey, descriptor) {
+ const originalFn = descriptor.value;
+ descriptor.value = async function(...args) {
+ return await originalFn.apply(this, args);
+ };
+ return descriptor;
+ };
+}
+class SomeClass {
+ async test() {}
+}
+__decorate1([
+ Decorator()
+], SomeClass.prototype, "test", null);
+new SomeClass().test();
+new B().method();
+[WILDCARD] \ No newline at end of file
diff --git a/cli/tests/testdata/bundle/decorators/ts_decorators.ts b/cli/tests/testdata/bundle/decorators/ts_decorators.ts
new file mode 100644
index 000000000..61299bccf
--- /dev/null
+++ b/cli/tests/testdata/bundle/decorators/ts_decorators.ts
@@ -0,0 +1,25 @@
+// deno-lint-ignore-file
+
+import { B } from "../../subdir/more_decorators.ts";
+
+function Decorator() {
+ return function (
+ target: Record<string, any>,
+ propertyKey: string,
+ descriptor: TypedPropertyDescriptor<any>,
+ ) {
+ const originalFn: Function = descriptor.value as Function;
+ descriptor.value = async function (...args: any[]) {
+ return await originalFn.apply(this, args);
+ };
+ return descriptor;
+ };
+}
+
+class SomeClass {
+ @Decorator()
+ async test() {}
+}
+
+new SomeClass().test();
+new B().method();
diff --git a/cli/tests/testdata/bundle/dynamic_import.ts b/cli/tests/testdata/bundle/dynamic_import.ts
new file mode 100644
index 000000000..d8c7d08ec
--- /dev/null
+++ b/cli/tests/testdata/bundle/dynamic_import.ts
@@ -0,0 +1,3 @@
+const mod1 = await import("http://localhost:4545/subdir/mod1.ts");
+
+mod1.printHello3();
diff --git a/cli/tests/testdata/bundle/ignore_directives.test.out b/cli/tests/testdata/bundle/ignore_directives.test.out
new file mode 100644
index 000000000..b69c2632c
--- /dev/null
+++ b/cli/tests/testdata/bundle/ignore_directives.test.out
@@ -0,0 +1,6 @@
+[WILDCARD]
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+// This code was bundled using `deno bundle` and it's not recommended to edit it manually
+
+[WILDCARD]
diff --git a/cli/tests/testdata/bundle/import_map/import_map.json b/cli/tests/testdata/bundle/import_map/import_map.json
new file mode 100644
index 000000000..c02f72718
--- /dev/null
+++ b/cli/tests/testdata/bundle/import_map/import_map.json
@@ -0,0 +1,5 @@
+{
+ "imports": {
+ "mod2": "../../subdir/subdir2/mod2.ts"
+ }
+}
diff --git a/cli/tests/testdata/bundle/import_map/main.ts b/cli/tests/testdata/bundle/import_map/main.ts
new file mode 100644
index 000000000..74834de20
--- /dev/null
+++ b/cli/tests/testdata/bundle/import_map/main.ts
@@ -0,0 +1,17 @@
+import { printHello2, returnsFoo } from "mod2";
+
+export function returnsHi(): string {
+ return "Hi";
+}
+
+export function returnsFoo2(): string {
+ return returnsFoo();
+}
+
+export function printHello3() {
+ printHello2();
+}
+
+export function throwsError() {
+ throw Error("exception from mod1");
+}
diff --git a/cli/tests/testdata/bundle/jsx.out b/cli/tests/testdata/bundle/jsx.out
new file mode 100644
index 000000000..da83cde82
--- /dev/null
+++ b/cli/tests/testdata/bundle/jsx.out
@@ -0,0 +1,9 @@
+[WILDCARD]
+const React = {
+ createElement () {}
+};
+function app() {
+ return React.createElement("div", null, React.createElement("h2", null, "asdf"));
+}
+console.log(app);
+
diff --git a/cli/tests/testdata/bundle/lockfile/check_error.json b/cli/tests/testdata/bundle/lockfile/check_error.json
new file mode 100644
index 000000000..a218d7000
--- /dev/null
+++ b/cli/tests/testdata/bundle/lockfile/check_error.json
@@ -0,0 +1,5 @@
+{
+ "http://127.0.0.1:4545/subdir/mod1.ts": "bfc1037b02c99abc20367f739bca7455813a5950066abd77965bff33b6eece0f",
+ "http://127.0.0.1:4545/subdir/print_hello.ts": "fa6692c8f9ff3fb107e773c3ece5274e9d08be282867a1e3ded1d9c00fcaa63c",
+ "http://127.0.0.1:4545/subdir/subdir2/mod2.ts": "bad"
+}
diff --git a/cli/tests/testdata/bundle/lockfile/check_error.out b/cli/tests/testdata/bundle/lockfile/check_error.out
new file mode 100644
index 000000000..9299bc27e
--- /dev/null
+++ b/cli/tests/testdata/bundle/lockfile/check_error.out
@@ -0,0 +1,4 @@
+[WILDCARD]
+error: The source code is invalid, as it does not match the expected hash in the lock file.
+ Specifier: http://127.0.0.1:4545/subdir/subdir2/mod2.ts
+ Lock file: bundle/lockfile/check_error.json