test(common): run common/http tests with Bazel (#24738)
@angular/common/http had tests which were not executed in Bazel. This commit adds a BUILD.bazel file and ensures the tests pass. PR Close #24738
This commit is contained in:
parent
ee50ee493d
commit
d05d28629d
|
@ -0,0 +1,35 @@
|
||||||
|
load("//tools:defaults.bzl", "ts_library", "ts_web_test_suite")
|
||||||
|
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||||
|
|
||||||
|
ts_library(
|
||||||
|
name = "test_lib",
|
||||||
|
testonly = 1,
|
||||||
|
srcs = glob(
|
||||||
|
["**/*.ts"],
|
||||||
|
exclude = ["**/*_node_only_spec.ts"],
|
||||||
|
),
|
||||||
|
deps = [
|
||||||
|
"//packages/common/http",
|
||||||
|
"//packages/common/http/testing",
|
||||||
|
"//packages/core",
|
||||||
|
"//packages/core/testing",
|
||||||
|
"@rxjs",
|
||||||
|
"@rxjs//operators",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
jasmine_node_test(
|
||||||
|
name = "test",
|
||||||
|
bootstrap = ["angular/tools/testing/init_node_spec.js"],
|
||||||
|
deps = [
|
||||||
|
":test_lib",
|
||||||
|
"//tools/testing:node",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
ts_web_test_suite(
|
||||||
|
name = "test_web",
|
||||||
|
deps = [
|
||||||
|
":test_lib",
|
||||||
|
],
|
||||||
|
)
|
|
@ -76,13 +76,17 @@ class SampleTokenExtractor {
|
||||||
it('does not re-parse if document.cookie has not changed', () => {
|
it('does not re-parse if document.cookie has not changed', () => {
|
||||||
expect(extractor.getToken()).toEqual('test');
|
expect(extractor.getToken()).toEqual('test');
|
||||||
expect(extractor.getToken()).toEqual('test');
|
expect(extractor.getToken()).toEqual('test');
|
||||||
expect(extractor.parseCount).toEqual(1);
|
expect(getParseCount(extractor)).toEqual(1);
|
||||||
});
|
});
|
||||||
it('re-parses if document.cookie changes', () => {
|
it('re-parses if document.cookie changes', () => {
|
||||||
expect(extractor.getToken()).toEqual('test');
|
expect(extractor.getToken()).toEqual('test');
|
||||||
document['cookie'] = 'XSRF-TOKEN=blah';
|
document['cookie'] = 'XSRF-TOKEN=blah';
|
||||||
expect(extractor.getToken()).toEqual('blah');
|
expect(extractor.getToken()).toEqual('blah');
|
||||||
expect(extractor.parseCount).toEqual(2);
|
expect(getParseCount(extractor)).toEqual(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getParseCount(extractor: HttpXsrfCookieExtractor): number {
|
||||||
|
return (extractor as any).parseCount;
|
||||||
|
}
|
Loading…
Reference in New Issue