aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgenii Kliuchnikov <eustas@google.com>2023-07-05 18:49:09 +0000
committerEvgenii Kliuchnikov <eustas.ru@gmail.com>2023-07-05 19:15:41 +0000
commitdd3eb162b071dbceb227d29bd523a37aff712219 (patch)
tree3f76af1760a3dac7a16483770f4c171d2238e354
parent11b8d7cb8aeae469bac87393f817db280e5df1cf (diff)
downloadbrotli-dd3eb162b071dbceb227d29bd523a37aff712219.zip
brotli-dd3eb162b071dbceb227d29bd523a37aff712219.tar.gz
brotli-dd3eb162b071dbceb227d29bd523a37aff712219.tar.bz2
Fix JS tests
PiperOrigin-RevId: 545743271
-rw-r--r--js/BUILD48
-rw-r--r--js/decode_synth_test.js5
-rw-r--r--js/jasmine-polyfill.js35
3 files changed, 84 insertions, 4 deletions
diff --git a/js/BUILD b/js/BUILD
index 19d2a39..d74e42c 100644
--- a/js/BUILD
+++ b/js/BUILD
@@ -19,6 +19,18 @@ closure_js_library(
],
)
+closure_js_library(
+ name = "jasmine-polyfill",
+ srcs = ["jasmine-polyfill.js"],
+ suppress = [
+ "JSC_MISSING_JSDOC",
+ "JSC_UNKNOWN_EXPR_TYPE",
+ "JSC_MISSING_PROVIDE",
+ ],
+ deps = ["@io_bazel_rules_closure//closure/library:testing"],
+ testonly = True,
+)
+
# Do NOT use this artifact; it is for test purposes only.
closure_js_library(
name = "decode",
@@ -28,13 +40,45 @@ closure_js_library(
)
closure_js_test(
- name = "all_tests",
+ name = "decode_test",
srcs = ["decode_test.js"],
entry_points = ["decode_test.js"],
suppress = ["moduleLoad"],
deps = [
":decode",
+ ":jasmine-polyfill",
+ ":polyfill",
+ ],
+)
+
+closure_js_test(
+ name = "decode_synth_test",
+ srcs = ["decode_synth_test.js"],
+ entry_points = ["decode_synth_test.js"],
+ suppress = ["moduleLoad"],
+ deps = [
+ ":decode",
+ ":jasmine-polyfill",
+ ":polyfill",
+ ],
+)
+
+closure_js_library(
+ name = "test_data_js",
+ testonly = True,
+ srcs = ["test_data.js"],
+ suppress = ["lintChecks"],
+)
+
+closure_js_test(
+ name = "bundle_test",
+ srcs = ["bundle_test.js"],
+ entry_points = ["bundle_test.js"],
+ suppress = ["moduleLoad"],
+ deps = [
+ ":decode",
+ ":jasmine-polyfill",
":polyfill",
- "@io_bazel_rules_closure//closure/library:testing",
+ ":test_data_js",
],
)
diff --git a/js/decode_synth_test.js b/js/decode_synth_test.js
index d321a88..34ab537 100644
--- a/js/decode_synth_test.js
+++ b/js/decode_synth_test.js
@@ -2289,7 +2289,8 @@ testZeroCostLiterals() {
describe("DecodeSynthTest", () => {
const testNames = Object.keys(allTests);
for (let i = 0; i < testNames.length; ++i) {
- const testName = testNames[i];
- it(testName, allTests[testName]);
+ const key = testNames[i];
+ const testName = key.replace(/\$/g, '');
+ it(testName, allTests[key]);
}
});
diff --git a/js/jasmine-polyfill.js b/js/jasmine-polyfill.js
new file mode 100644
index 0000000..69d7ec4
--- /dev/null
+++ b/js/jasmine-polyfill.js
@@ -0,0 +1,35 @@
+goog.require('goog.testing.TestCase');
+goog.require('goog.testing.asserts');
+goog.require('goog.testing.jsunit');
+
+let test_case_;
+
+function describe(caseName, callback) {
+ test_case_ = new goog.testing.TestCase(caseName);
+ callback();
+ window['G_testRunner'].initialize(test_case_);
+}
+
+function it(testName, callback) {
+ test_case_.add(new goog.testing.TestCase.Test(testName, callback));
+}
+
+/**
+ * @param {*} actual
+ * @constructor
+ */
+function Expect(actual) {
+ this.actual = actual;
+}
+
+Expect.prototype.toEqual = function(expected) {
+ assertEquals(expected, this.actual);
+};
+
+/**
+ * @param {*} actual
+ * @returns {!Expect}
+ */
+function expect(actual) {
+ return new Expect(actual);
+}