mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(init): use bare specifier for jsr:@std/assert
(#24581)
Closes #24580
This commit is contained in:
parent
e0cfc9da39
commit
8754a01d43
9 changed files with 68 additions and 12 deletions
|
@ -39,7 +39,7 @@ pub fn init_project(init_flags: InitFlags) -> Result<(), AnyError> {
|
||||||
create_file(
|
create_file(
|
||||||
&dir,
|
&dir,
|
||||||
"mod_test.ts",
|
"mod_test.ts",
|
||||||
r#"import { assertEquals } from "jsr:@std/assert";
|
r#"import { assertEquals } from "@std/assert";
|
||||||
import { add } from "./mod.ts";
|
import { add } from "./mod.ts";
|
||||||
|
|
||||||
Deno.test(function addTest() {
|
Deno.test(function addTest() {
|
||||||
|
@ -53,11 +53,14 @@ Deno.test(function addTest() {
|
||||||
"deno.json",
|
"deno.json",
|
||||||
&json!({
|
&json!({
|
||||||
"name": project_name,
|
"name": project_name,
|
||||||
"version": "1.0.0",
|
"version": "0.1.0",
|
||||||
"exports": "./mod.ts",
|
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"dev": "deno test --watch mod.ts"
|
"dev": "deno test --watch mod.ts"
|
||||||
}
|
},
|
||||||
|
"imports": {
|
||||||
|
"@std/assert": "jsr:@std/assert@1"
|
||||||
|
},
|
||||||
|
"exports": "./mod.ts"
|
||||||
}),
|
}),
|
||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,7 +80,7 @@ if (import.meta.main) {
|
||||||
create_file(
|
create_file(
|
||||||
&dir,
|
&dir,
|
||||||
"main_test.ts",
|
"main_test.ts",
|
||||||
r#"import { assertEquals } from "jsr:@std/assert";
|
r#"import { assertEquals } from "@std/assert";
|
||||||
import { add } from "./main.ts";
|
import { add } from "./main.ts";
|
||||||
|
|
||||||
Deno.test(function addTest() {
|
Deno.test(function addTest() {
|
||||||
|
@ -92,6 +95,9 @@ Deno.test(function addTest() {
|
||||||
&json!({
|
&json!({
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"dev": "deno run --watch main.ts"
|
"dev": "deno run --watch main.ts"
|
||||||
|
},
|
||||||
|
"imports": {
|
||||||
|
"@std/assert": "jsr:@std/assert@1"
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)?;
|
)?;
|
||||||
|
|
|
@ -81,7 +81,8 @@ fn init_subcommand_with_dir_arg() {
|
||||||
let output = context
|
let output = context
|
||||||
.new_command()
|
.new_command()
|
||||||
.env("NO_COLOR", "1")
|
.env("NO_COLOR", "1")
|
||||||
.args("test my_dir/main_test.ts")
|
.current_dir("my_dir")
|
||||||
|
.args("test main_test.ts")
|
||||||
.split_output()
|
.split_output()
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
|
4
tests/registry/jsr/@std/assert/1.0.0/assert.ts
Normal file
4
tests/registry/jsr/@std/assert/1.0.0/assert.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
export function assert(expr: unknown) {
|
||||||
|
return true;
|
||||||
|
}
|
9
tests/registry/jsr/@std/assert/1.0.0/assert_equals.ts
Normal file
9
tests/registry/jsr/@std/assert/1.0.0/assert_equals.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
export function assertEquals<T>(
|
||||||
|
actual: T,
|
||||||
|
expected: T,
|
||||||
|
msg?: string,
|
||||||
|
options: { formatter?: (value: unknown) => string } = {},
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
5
tests/registry/jsr/@std/assert/1.0.0/fail.ts
Normal file
5
tests/registry/jsr/@std/assert/1.0.0/fail.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
export function fail() {
|
||||||
|
return true;
|
||||||
|
}
|
22
tests/registry/jsr/@std/assert/1.0.0/mod.ts
Normal file
22
tests/registry/jsr/@std/assert/1.0.0/mod.ts
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
/** A library of assertion functions.
|
||||||
|
* If the assertion is false an `AssertionError` will be thrown which will
|
||||||
|
* result in pretty-printed diff of failing assertion.
|
||||||
|
*
|
||||||
|
* This module is browser compatible, but do not rely on good formatting of
|
||||||
|
* values for AssertionError messages in browsers.
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* import { assert } from "@std/assert/assert";
|
||||||
|
*
|
||||||
|
* assert("I am truthy"); // Doesn't throw
|
||||||
|
* assert(false); // Throws `AssertionError`
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @module
|
||||||
|
*/
|
||||||
|
|
||||||
|
export * from "./assert_equals.ts";
|
||||||
|
export * from "./assert.ts";
|
||||||
|
export * from "./fail.ts";
|
8
tests/registry/jsr/@std/assert/1.0.0_meta.json
Normal file
8
tests/registry/jsr/@std/assert/1.0.0_meta.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"exports": {
|
||||||
|
".": "./mod.ts",
|
||||||
|
"./assert": "./assert.ts",
|
||||||
|
"./assert-equals": "./assert-equals.ts",
|
||||||
|
"./fail": "./fail.ts"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
{
|
{
|
||||||
"scope": "std",
|
"scope": "std",
|
||||||
"name": "assert",
|
"name": "assert",
|
||||||
"latest": "0.220.1",
|
"latest": "1.0.0",
|
||||||
"versions": {
|
"versions": {
|
||||||
|
"1.0.0": {},
|
||||||
"0.220.1": {}
|
"0.220.1": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
Download http://127.0.0.1:4250/@std/assert/meta.json
|
Download http://127.0.0.1:4250/@std/assert/meta.json
|
||||||
Download http://127.0.0.1:4250/@std/assert/0.220.1_meta.json
|
Download http://127.0.0.1:4250/@std/assert/1.0.0_meta.json
|
||||||
[UNORDERED_START]
|
[UNORDERED_START]
|
||||||
Download http://127.0.0.1:4250/@std/assert/0.220.1/mod.ts
|
Download http://127.0.0.1:4250/@std/assert/1.0.0/mod.ts
|
||||||
Download http://127.0.0.1:4250/@std/assert/0.220.1/assert_equals.ts
|
Download http://127.0.0.1:4250/@std/assert/1.0.0/assert_equals.ts
|
||||||
Download http://127.0.0.1:4250/@std/assert/0.220.1/assert.ts
|
Download http://127.0.0.1:4250/@std/assert/1.0.0/assert.ts
|
||||||
Download http://127.0.0.1:4250/@std/assert/0.220.1/fail.ts
|
Download http://127.0.0.1:4250/@std/assert/1.0.0/fail.ts
|
||||||
[UNORDERED_END]
|
[UNORDERED_END]
|
||||||
Check file:///[WILDLINE]/mod_test.ts
|
Check file:///[WILDLINE]/mod_test.ts
|
||||||
running 1 test from ./mod_test.ts
|
running 1 test from ./mod_test.ts
|
||||||
|
|
Loading…
Reference in a new issue