Merge pull request #1243 from hgiesel/actualtest

Add minimal tests to html-filter
This commit is contained in:
Damien Elmes 2021-06-19 22:26:59 +10:00 committed by GitHub
commit 42c71cd204
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View file

@ -5,17 +5,18 @@ load("//ts:eslint.bzl", "eslint_test")
ts_library(
name = "html-filter",
module_name = "html-filter",
srcs = glob(
["*.ts"],
exclude = ["*.test.ts"],
),
module_name = "html-filter",
tsconfig = "//ts:tsconfig.json",
visibility = ["//visibility:public"],
deps = [],
)
jest_test(
env = "jsdom",
deps = [
"html-filter",
],

View file

@ -1,6 +1,12 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
test("it should work", () => {
expect("test").toBe("test");
import { filterHTML } from ".";
describe("filterHTML", () => {
test("zero input creates zero output", () => {
expect(filterHTML("", true, false)).toBe("");
expect(filterHTML("", true, false)).toBe("");
expect(filterHTML("", false, false)).toBe("");
});
});

View file

@ -2,7 +2,7 @@ load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("@esbuild_toolchain//:esbuild.bzl", esbuild = "esbuild_macro")
load("@npm//jest-cli:index.bzl", _jest_test = "jest_test")
def jest_test(deps, name = "jest", protobuf = False):
def jest_test(deps, name = "jest", protobuf = False, env = "node"):
"Build *.test.ts into a library, then test it with Jest."
ts_sources = native.glob(["*.test.ts"])
@ -61,6 +61,7 @@ def jest_test(deps, name = "jest", protobuf = False):
"--colors",
"--config",
"$(location //ts:jest.config.js)",
"--env=" + env,
],
data = bundled_srcs + [
"//ts:jest.config.js",