Skip to main content
Module

x/unitest/mod.ts>toBeHexColor

🃏 Deno-first universal unit testing framework
Latest
function toBeHexColor
Re-export
import { toBeHexColor } from "https://deno.land/x/unitest@v1.0.0-beta.82/mod.ts";

Use .toBeHexadecimal when checking if a value is a valid HTML hex color

import {
  defineExpect,
  not,
  test,
  toBeHexColor,
} from "https://deno.land/x/unitest@$VERSION/mod.ts";

const expect = defineExpect({
  matcherMap: {
    toBeHexColor,
  },
  modifierMap: {
    not,
  },
});

test("passes when value is a valid hex color", () => {
  expect("#abc123").toBeHexColor();
  expect("#FFF").toBeHexColor();
  expect("#000000").toBeHexColor();
  expect("#123ffg").not.toBeHexColor();
});

Parameters

actual: string