diff --git a/Cargo.lock b/Cargo.lock index 68934530..89297a9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -213,9 +213,9 @@ dependencies = [ [[package]] name = "deno_core" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40385b8a20c2092edcf63befe8c3e8f1b79bbe2c68616a156a7488c2644baecb" +checksum = "106fdf021a2bde6d532c1fa9c51ab8f19d4cd4314f5f8d01db20479fc9a9be0a" dependencies = [ "downcast-rs", "futures 0.3.4", @@ -1041,9 +1041,9 @@ dependencies = [ [[package]] name = "rusty_v8" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee528081d3eb7efe829a0021063df092a241837f3c063fb825bf7aa8858f80c" +checksum = "01403323dd70ffeace922e35555ca0c15223a20a4e1cf8f35cc4f68fadb3e285" dependencies = [ "bitflags", "cargo_gn", @@ -1076,18 +1076,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e707fbbf255b8fc8c3b99abb91e7257a622caeb20a9818cbadbeeede4e0932ff" +checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac5d00fc561ba2724df6758a17de23df5914f20e41cb00f94d5b7ae42fffaff8" +checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" dependencies = [ "proc-macro2 1.0.8", "quote 1.0.2", diff --git a/ts/tests/types-check.test.ts b/ts/tests/types-check.test.ts index 96812503..fbb8ef7a 100644 --- a/ts/tests/types-check.test.ts +++ b/ts/tests/types-check.test.ts @@ -1,7 +1,9 @@ -import { assertThrows } from "https://deno.land/std@v0.35.0/testing/asserts.ts"; +import { assertEquals, assertThrows } from "../../test.deps.ts"; import { ObjectId } from "../types.ts"; Deno.test("ObjectId parse", function() { - assertThrows(() => ObjectId("d3e48b03-7baf-4d98-8df7-5002a8fae5e4")); - ObjectId("5e63a91b00d839ae0084dfe4"); + let $oid = "d3e48b03-7baf-4d98-8df7-5002a8fae5e4"; + assertThrows(() => ObjectId($oid)); + $oid = "5e63a91b00d839ae0084dfe4"; + assertEquals(ObjectId($oid), { $oid }); }); diff --git a/ts/types.ts b/ts/types.ts index 783f6b7d..9df2467a 100644 --- a/ts/types.ts +++ b/ts/types.ts @@ -1,5 +1,3 @@ -import { assert } from "https://deno.land/std@v0.35.0/testing/asserts.ts"; - export enum CommandType { ConnectWithUri = "ConnectWithUri", ConnectWithOptions = "ConnectWithOptions", @@ -20,7 +18,9 @@ export interface ObjectId { } export function ObjectId($oid: string) { const isLegal = /[0-9a-fA-F]{24}/.test($oid); - assert(isLegal, `ObjectId("${$oid}") is not legal.`); + if (!isLegal) { + throw new Error(`ObjectId("${$oid}") is not legal.`); + } return { $oid }; }