deno.land / std@0.224.0 / assert / assert_string_includes_test.ts
1234567891011121314151617181920212223242526272829303132333435363738// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.import { assert, assertEquals, AssertionError, assertStringIncludes,} from "./mod.ts";
Deno.test("AssertStringIncludes", function () { assertStringIncludes("Denosaurus", "saur"); assertStringIncludes("Denosaurus", "Deno"); assertStringIncludes("Denosaurus", "rus"); let didThrow; try { assertStringIncludes("Denosaurus", "Raptor"); didThrow = false; } catch (e) { assert(e instanceof AssertionError); didThrow = true; } assertEquals(didThrow, true);});
Deno.test("AssertStringContainsThrow", function () { let didThrow = false; try { assertStringIncludes("Denosaurus from Jurassic", "Raptor"); } catch (e) { assert(e instanceof AssertionError); assert( e.message === `Expected actual: "Denosaurus from Jurassic" to contain: "Raptor".`, ); didThrow = true; } assert(didThrow);});
Version Info