diff options
Diffstat (limited to 'cli/tests/testdata')
15 files changed, 138 insertions, 0 deletions
diff --git a/cli/tests/testdata/fmt/deno.jsonc b/cli/tests/testdata/fmt/deno.jsonc new file mode 100644 index 000000000..0e682cf36 --- /dev/null +++ b/cli/tests/testdata/fmt/deno.jsonc @@ -0,0 +1,15 @@ +{ + "fmt": { + "files": { + "include": ["fmt/fmt_with_config/"], + "exclude": ["fmt/fmt_with_config/b.ts"] + }, + "options": { + "useTabs": true, + "lineWidth": 40, + "indentWidth": 8, + "singleQuote": true, + "proseWrap": "always" + } + } +} diff --git a/cli/tests/testdata/fmt/deno.malformed.jsonc b/cli/tests/testdata/fmt/deno.malformed.jsonc new file mode 100644 index 000000000..667480bdc --- /dev/null +++ b/cli/tests/testdata/fmt/deno.malformed.jsonc @@ -0,0 +1,12 @@ +{ + "fmt": { + "files": { + "include": ["fmt/fmt_with_config/"], + "exclude": ["fmt/fmt_with_config/b.ts"] + }, + "dont_know_this_field": {}, + "options": { + "useTabs": true + } + } +} diff --git a/cli/tests/testdata/fmt/deno.malformed2.jsonc b/cli/tests/testdata/fmt/deno.malformed2.jsonc new file mode 100644 index 000000000..2210dc0c7 --- /dev/null +++ b/cli/tests/testdata/fmt/deno.malformed2.jsonc @@ -0,0 +1,12 @@ +{ + "fmt": { + "files": { + "include": ["fmt/fmt_with_config/"], + "exclude": ["fmt/fmt_with_config/b.ts"], + "dont_know_this_field": {} + }, + "options": { + "useTabs": true + } + } +} diff --git a/cli/tests/testdata/fmt/fmt_with_config.out b/cli/tests/testdata/fmt/fmt_with_config.out new file mode 100644 index 000000000..158c556c2 --- /dev/null +++ b/cli/tests/testdata/fmt/fmt_with_config.out @@ -0,0 +1 @@ +Checked 2 files diff --git a/cli/tests/testdata/fmt/fmt_with_config/a.ts b/cli/tests/testdata/fmt/fmt_with_config/a.ts new file mode 100644 index 000000000..e0f32647b --- /dev/null +++ b/cli/tests/testdata/fmt/fmt_with_config/a.ts @@ -0,0 +1,46 @@ +unitTest( + { perms: { net: true } }, + async function responseClone() { + const response = + await fetch( + 'http://localhost:4545/fixture.json', + ); + const response1 = + response.clone(); + assert( + response !== + response1, + ); + assertEquals( + response.status, + response1 + .status, + ); + assertEquals( + response.statusText, + response1 + .statusText, + ); + const u8a = + new Uint8Array( + await response + .arrayBuffer(), + ); + const u8a1 = + new Uint8Array( + await response1 + .arrayBuffer(), + ); + for ( + let i = 0; + i < + u8a.byteLength; + i++ + ) { + assertEquals( + u8a[i], + u8a1[i], + ); + } + }, +); diff --git a/cli/tests/testdata/fmt/fmt_with_config/b.ts b/cli/tests/testdata/fmt/fmt_with_config/b.ts new file mode 100644 index 000000000..5c37d51d2 --- /dev/null +++ b/cli/tests/testdata/fmt/fmt_with_config/b.ts @@ -0,0 +1,15 @@ +// This file should be excluded from formatting +unitTest( + { perms: { net: true } }, + async function fetchBodyUsedCancelStream() { + const response = await fetch( + "http://localhost:4545/fixture.json", + ); + assert(response.body !== null); + + assertEquals(response.bodyUsed, false); + const promise = response.body.cancel(); + assertEquals(response.bodyUsed, true); + await promise; + }, +);
\ No newline at end of file diff --git a/cli/tests/testdata/fmt/fmt_with_config/c.md b/cli/tests/testdata/fmt/fmt_with_config/c.md new file mode 100644 index 000000000..012f7e3d4 --- /dev/null +++ b/cli/tests/testdata/fmt/fmt_with_config/c.md @@ -0,0 +1,17 @@ +## Permissions + +Deno is secure by default. Therefore, +unless you specifically enable it, a +program run with Deno has no file, +network, or environment access. Access +to security sensitive functionality +requires that permisisons have been +granted to an executing script through +command line flags, or a runtime +permission prompt. + +For the following example `mod.ts` has +been granted read-only access to the +file system. It cannot write to the file +system, or perform any other security +sensitive functions. diff --git a/cli/tests/testdata/fmt/fmt_with_config_and_flags.out b/cli/tests/testdata/fmt/fmt_with_config_and_flags.out new file mode 100644 index 000000000..c05ac45a1 --- /dev/null +++ b/cli/tests/testdata/fmt/fmt_with_config_and_flags.out @@ -0,0 +1 @@ +Checked 1 file diff --git a/cli/tests/testdata/fmt/fmt_with_malformed_config.out b/cli/tests/testdata/fmt/fmt_with_malformed_config.out new file mode 100644 index 000000000..1a55613ef --- /dev/null +++ b/cli/tests/testdata/fmt/fmt_with_malformed_config.out @@ -0,0 +1,4 @@ +error: Failed to parse "fmt" configuration + +Caused by: + unknown field `dont_know_this_field`, expected `options` or `files` diff --git a/cli/tests/testdata/fmt/fmt_with_malformed_config2.out b/cli/tests/testdata/fmt/fmt_with_malformed_config2.out new file mode 100644 index 000000000..948b6b5b8 --- /dev/null +++ b/cli/tests/testdata/fmt/fmt_with_malformed_config2.out @@ -0,0 +1,4 @@ +error: Failed to parse "fmt" configuration + +Caused by: + unknown field `dont_know_this_field`, expected `include` or `exclude` diff --git a/cli/tests/testdata/fmt/formatted1.js b/cli/tests/testdata/fmt/regular/formatted1.js index 587aa5b96..587aa5b96 100644 --- a/cli/tests/testdata/fmt/formatted1.js +++ b/cli/tests/testdata/fmt/regular/formatted1.js diff --git a/cli/tests/testdata/fmt/formatted2.ts b/cli/tests/testdata/fmt/regular/formatted2.ts index 4a8036806..4a8036806 100644 --- a/cli/tests/testdata/fmt/formatted2.ts +++ b/cli/tests/testdata/fmt/regular/formatted2.ts diff --git a/cli/tests/testdata/fmt/formatted3.md b/cli/tests/testdata/fmt/regular/formatted3.md index e6e616584..e6e616584 100644 --- a/cli/tests/testdata/fmt/formatted3.md +++ b/cli/tests/testdata/fmt/regular/formatted3.md diff --git a/cli/tests/testdata/fmt/formatted4.jsonc b/cli/tests/testdata/fmt/regular/formatted4.jsonc index f0f72a6ed..f0f72a6ed 100644 --- a/cli/tests/testdata/fmt/formatted4.jsonc +++ b/cli/tests/testdata/fmt/regular/formatted4.jsonc diff --git a/cli/tests/testdata/lsp/deno.fmt.jsonc b/cli/tests/testdata/lsp/deno.fmt.jsonc new file mode 100644 index 000000000..a0a851731 --- /dev/null +++ b/cli/tests/testdata/lsp/deno.fmt.jsonc @@ -0,0 +1,11 @@ +{ + "fmt": { + "options": { + "useTabs": true, + "lineWidth": 40, + "indentWidth": 8, + "singleQuote": true, + "proseWrap": "always" + } + } +} |