build: add bazel test rules for remainder of packages (#21053)
PR Close #21053
This commit is contained in:
23
packages/platform-webworker/BUILD.bazel
Normal file
23
packages/platform-webworker/BUILD.bazel
Normal file
@ -0,0 +1,23 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("@angular//:index.bzl", "ng_module")
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "platform-webworker",
|
||||
srcs = glob(
|
||||
[
|
||||
"*.ts",
|
||||
"src/**/*.ts",
|
||||
],
|
||||
),
|
||||
module_name = "@angular/platform-webworker",
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/common",
|
||||
"//packages/compiler",
|
||||
"//packages/core",
|
||||
"//packages/platform-browser",
|
||||
],
|
||||
)
|
20
packages/platform-webworker/test/BUILD.1.bazel
Normal file
20
packages/platform-webworker/test/BUILD.1.bazel
Normal file
@ -0,0 +1,20 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
|
||||
|
||||
ts_library(
|
||||
name = "testing",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
module_name = "@angular/platform-browser-dynamic/testing",
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages/compiler",
|
||||
"//packages/compiler/testing",
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-browser-dynamic",
|
||||
"//packages/platform-browser/testing",
|
||||
],
|
||||
)
|
41
packages/platform-webworker/test/BUILD.bazel
Normal file
41
packages/platform-webworker/test/BUILD.bazel
Normal file
@ -0,0 +1,41 @@
|
||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
|
||||
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
tsconfig = "//packages:tsconfig",
|
||||
deps = [
|
||||
"//packages:types",
|
||||
"//packages/compiler",
|
||||
"//packages/core",
|
||||
"//packages/core/testing",
|
||||
"//packages/platform-browser",
|
||||
"//packages/platform-browser-dynamic",
|
||||
"//packages/platform-browser-dynamic/testing",
|
||||
"//packages/platform-browser/testing",
|
||||
"//packages/platform-webworker",
|
||||
],
|
||||
)
|
||||
|
||||
jasmine_node_test(
|
||||
name = "test",
|
||||
bootstrap = ["angular_src/packages/_testing_init/init_node_spec.js"],
|
||||
deps = [
|
||||
":test_lib",
|
||||
"//packages/_testing_init:node",
|
||||
],
|
||||
)
|
||||
|
||||
ts_web_test(
|
||||
name = "test_web",
|
||||
bootstrap = [
|
||||
"//:angular_bootstrap_scripts",
|
||||
],
|
||||
# do not sort
|
||||
deps = [
|
||||
"//packages/_testing_init:browser",
|
||||
":test_lib",
|
||||
],
|
||||
)
|
@ -34,9 +34,10 @@ import {createPairedMessageBuses} from './web_worker_test_util';
|
||||
});
|
||||
it('should call registered method with correct arguments',
|
||||
inject([Serializer], (serializer: Serializer) => {
|
||||
const broker = new ServiceMessageBroker(messageBuses.ui, serializer, CHANNEL);
|
||||
const broker = new (ServiceMessageBroker as any)(messageBuses.ui, serializer, CHANNEL);
|
||||
broker.registerMethod(
|
||||
TEST_METHOD, [SerializerTypes.PRIMITIVE, SerializerTypes.PRIMITIVE], (arg1, arg2) => {
|
||||
TEST_METHOD, [SerializerTypes.PRIMITIVE, SerializerTypes.PRIMITIVE],
|
||||
(arg1: any, arg2: any) => {
|
||||
expect(arg1).toEqual(PASSED_ARG_1);
|
||||
expect(arg2).toEqual(PASSED_ARG_2);
|
||||
});
|
||||
@ -47,8 +48,8 @@ import {createPairedMessageBuses} from './web_worker_test_util';
|
||||
}));
|
||||
|
||||
it('should return promises to the worker', inject([Serializer], (serializer: Serializer) => {
|
||||
const broker = new ServiceMessageBroker(messageBuses.ui, serializer, CHANNEL);
|
||||
broker.registerMethod(TEST_METHOD, [SerializerTypes.PRIMITIVE], (arg1) => {
|
||||
const broker = new (ServiceMessageBroker as any)(messageBuses.ui, serializer, CHANNEL);
|
||||
broker.registerMethod(TEST_METHOD, [SerializerTypes.PRIMITIVE], (arg1: any) => {
|
||||
expect(arg1).toEqual(PASSED_ARG_1);
|
||||
return new Promise((res, rej) => {
|
||||
try {
|
||||
|
@ -130,7 +130,9 @@ export class MockMessageBus extends MessageBus {
|
||||
attachToZone(zone: NgZone) {}
|
||||
}
|
||||
|
||||
export class MockMessageBrokerFactory extends ClientMessageBrokerFactory {
|
||||
export const _ClientMessageBrokerFactory: {new (a: any, b: any): ClientMessageBrokerFactory} =
|
||||
ClientMessageBrokerFactory;
|
||||
export class MockMessageBrokerFactory extends _ClientMessageBrokerFactory {
|
||||
constructor(private _messageBroker: ClientMessageBroker) { super(null !, null !); }
|
||||
createMessageBroker(channel: string, runInZone = true) { return this._messageBroker; }
|
||||
}
|
||||
|
@ -67,18 +67,18 @@ import {SpyMessageBroker} from './spies';
|
||||
it('should get location on init', () => {
|
||||
const platformLocation = createWebWorkerPlatformLocation(null !);
|
||||
expectBrokerCall(broker, 'getLocation');
|
||||
platformLocation.init();
|
||||
(platformLocation as any).init();
|
||||
});
|
||||
|
||||
it('should throw if set pathname is called before init finishes', () => {
|
||||
const platformLocation = createWebWorkerPlatformLocation(null !);
|
||||
platformLocation.init();
|
||||
(platformLocation as any).init();
|
||||
expect(() => platformLocation.pathname = 'TEST').toThrowError();
|
||||
});
|
||||
|
||||
it('should send pathname to render thread', done => {
|
||||
const platformLocation = createWebWorkerPlatformLocation(TEST_LOCATION);
|
||||
platformLocation.init().then((_) => {
|
||||
(platformLocation as any).init().then((_: any) => {
|
||||
const PATHNAME = '/test';
|
||||
expectBrokerCall(broker, 'setPathname', [PATHNAME]);
|
||||
platformLocation.pathname = PATHNAME;
|
||||
|
@ -184,10 +184,10 @@ function createWebWorkerBrokerFactory(
|
||||
const wwMessageBus = messageBuses.worker;
|
||||
|
||||
// set up the worker side
|
||||
const wwBrokerFactory = new ClientMessageBrokerFactory(wwMessageBus, wwSerializer);
|
||||
const wwBrokerFactory = new (ClientMessageBrokerFactory as any)(wwMessageBus, wwSerializer);
|
||||
|
||||
// set up the ui side
|
||||
const uiBrokerFactory = new ServiceMessageBrokerFactory(uiMessageBus, uiSerializer);
|
||||
const uiBrokerFactory = new (ServiceMessageBrokerFactory as any)(uiMessageBus, uiSerializer);
|
||||
const renderer = new MessageBasedRenderer2(
|
||||
uiBrokerFactory, uiMessageBus, uiSerializer, uiRenderStore, domRendererFactory);
|
||||
renderer.start();
|
||||
|
Reference in New Issue
Block a user