mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
chore(npm): add explicit tests for module.exports
assignment with type checking (#16435)
This commit is contained in:
parent
1376c6932f
commit
a4d4acd1af
11 changed files with 56 additions and 0 deletions
|
@ -110,6 +110,20 @@ itest!(child_process_fork_test {
|
|||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(cjs_module_export_assignment {
|
||||
args: "run -A --unstable --quiet --check=all npm/cjs_module_export_assignment/main.ts",
|
||||
output: "npm/cjs_module_export_assignment/main.out",
|
||||
envs: env_vars(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(cjs_module_export_assignment_number {
|
||||
args: "run -A --unstable --quiet --check=all npm/cjs_module_export_assignment_number/main.ts",
|
||||
output: "npm/cjs_module_export_assignment_number/main.out",
|
||||
envs: env_vars(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
// FIXME(bartlomieju): npm: specifiers are not handled in dynamic imports
|
||||
// at the moment
|
||||
// itest!(dynamic_import {
|
||||
|
|
3
cli/tests/testdata/npm/cjs_module_export_assignment/main.out
vendored
Normal file
3
cli/tests/testdata/npm/cjs_module_export_assignment/main.out
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{ func: [Function: func] }
|
||||
Module { default: { func: [Function: func] }, func: [Function: func] }
|
||||
5
|
6
cli/tests/testdata/npm/cjs_module_export_assignment/main.ts
vendored
Normal file
6
cli/tests/testdata/npm/cjs_module_export_assignment/main.ts
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
import defaultImport, * as namespaceImport from "npm:@denotest/cjs-module-export-assignment";
|
||||
import { func } from "npm:@denotest/cjs-module-export-assignment";
|
||||
|
||||
console.log(defaultImport);
|
||||
console.log(namespaceImport);
|
||||
console.log(func());
|
3
cli/tests/testdata/npm/cjs_module_export_assignment_number/main.out
vendored
Normal file
3
cli/tests/testdata/npm/cjs_module_export_assignment_number/main.out
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
5
|
||||
5
|
||||
Module { default: 5 }
|
7
cli/tests/testdata/npm/cjs_module_export_assignment_number/main.ts
vendored
Normal file
7
cli/tests/testdata/npm/cjs_module_export_assignment_number/main.ts
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
import defaultImport, * as namespaceImport from "npm:@denotest/cjs-module-export-assignment-number";
|
||||
|
||||
const testDefault: 5 = defaultImport;
|
||||
console.log(testDefault);
|
||||
const testNamespace: 5 = namespaceImport.default;
|
||||
console.log(testNamespace);
|
||||
console.log(namespaceImport);
|
|
@ -0,0 +1,2 @@
|
|||
declare const value = 5;
|
||||
export = value;
|
1
cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment-number/1.0.0/index.js
vendored
Normal file
1
cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment-number/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = 5;
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "@denotest/cjs-module-export-assignment-number",
|
||||
"version": "1.0.0",
|
||||
"types": "./index.d.ts"
|
||||
}
|
5
cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/index.d.ts
vendored
Normal file
5
cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/index.d.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
declare module ThisModule {
|
||||
function func(): 5;
|
||||
}
|
||||
|
||||
export = ThisModule;
|
5
cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/index.js
vendored
Normal file
5
cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
func() {
|
||||
return 5;
|
||||
},
|
||||
};
|
5
cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/package.json
vendored
Normal file
5
cli/tests/testdata/npm/registry/@denotest/cjs-module-export-assignment/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "@denotest/cjs-module-export-assignment",
|
||||
"version": "1.0.0",
|
||||
"types": "./index.d.ts"
|
||||
}
|
Loading…
Reference in a new issue