blob: 4e3275bda0ff3ecf1a4dfe330cd2cff73850d747 [file] [log] [blame]
Sean Condon98b6ddb2019-12-24 08:07:40 +00001load("@npm_angular_bazel//:index.bzl", "ng_module")
Sean Condona3ad7792020-01-04 19:26:34 +00002load("@npm_bazel_typescript//:index.bzl", "ts_library")
3load("@npm_bazel_karma//:index.bzl", "karma_web_test_suite")
Sean Condon98b6ddb2019-12-24 08:07:40 +00004
5package(default_visibility = ["//:__subpackages__"])
6
7# We don't import from these, but the generated ngfactory code will
8NG_FACTORY_ADDED_IMPORTS = [
9 "@npm//@angular/animations",
10 "@npm//@angular/forms",
11]
12
13ng_module(
14 name = "gui2-topo-lib",
15 srcs = glob(
16 include = ["**/*.ts"],
17 exclude = [
18 "**/*.spec.ts",
Sean Condon98b6ddb2019-12-24 08:07:40 +000019 ],
20 ),
21 assets = glob([
22 "**/*.css",
23 "**/*.html",
24 ]),
Sean Condona3ad7792020-01-04 19:26:34 +000025 tsconfig = "//web/gui2:tsconfig.json",
Sean Condon98b6ddb2019-12-24 08:07:40 +000026 deps = NG_FACTORY_ADDED_IMPORTS + [
27 "//web/gui2-fw-lib",
28 "@npm//@angular/core",
29 "@npm//@angular/router",
30 "@npm//@angular/platform-browser",
31 "@npm//rxjs",
32 "@npm//@types",
33 "@npm//topojson-client",
34 ],
35)
Sean Condona3ad7792020-01-04 19:26:34 +000036
37ts_library(
38 name = "test_lib",
39 testonly = 1,
40 srcs = glob(
41 include = ["**/*.spec.ts"],
42 # TODO re-enable this test
43 exclude = [
44 "lib/layer/backgroundsvg/backgroundsvg.component.spec.ts",
45 "lib/layer/forcesvg/forcesvg.component.spec.ts",
46 ],
47 ),
48 tsconfig = "//web/gui2:tsconfig-test",
49 deps = [
50 ":gui2-topo-lib",
51 "//web/gui2-fw-lib",
52 "@npm//@angular/common",
53 "@npm//@angular/core",
54 "@npm//@angular/forms",
55 "@npm//@angular/http",
56 "@npm//@angular/platform-browser",
57 "@npm//@angular/router",
58 "@npm//@types/jasmine",
59 "@npm//rxjs",
60 ],
61)
62
63# Convert topojson-client to an AMD module so it can be loaded in the RequireJS test environment.
64genrule(
65 name = "topojson-client_requirejs",
66 srcs = [
67 "@npm//:node_modules/topojson-client/dist/topojson-client.js",
68 ],
69 outs = [
70 "topojson-client.js",
71 ],
72 cmd = """echo "define('topojson-client', function(require, exports, module) {" > $@ \
73 && cat $< >> $@ \
74 && echo '});' >> $@""",
75)
76
77# Convert d3-force to an AMD module so it can be loaded in the RequireJS test environment.
78genrule(
79 name = "d3-force_requirejs",
80 srcs = [
81 "@npm//:node_modules/d3-force/dist/d3-force.js",
82 ],
83 outs = [
84 "d3-force.js",
85 ],
86 cmd = """echo "define('d3-force', function(require, exports, module) {" > $@ \
87 && cat $< >> $@ \
88 && echo '});' >> $@""",
89)
90
91# Convert d3-quadtree to an AMD module so it can be loaded in the RequireJS test environment.
92genrule(
93 name = "d3-quadtree_requirejs",
94 srcs = [
95 "@npm//:node_modules/d3-quadtree/dist/d3-quadtree.js",
96 ],
97 outs = [
98 "d3-quadtree.js",
99 ],
100 cmd = """echo "define('d3-quadtree', function(require, exports, module) {" > $@ \
101 && cat $< >> $@ \
102 && echo '});' >> $@""",
103)
104
105# Convert d3-collection to an AMD module so it can be loaded in the RequireJS test environment.
106genrule(
107 name = "d3-collection_requirejs",
108 srcs = [
109 "@npm//:node_modules/d3-collection/dist/d3-collection.js",
110 ],
111 outs = [
112 "d3-collection.js",
113 ],
114 cmd = """echo "define('d3-collection', function(require, exports, module) {" > $@ \
115 && cat $< >> $@ \
116 && echo '});' >> $@""",
117)
118
119# Convert d3-dispatch to an AMD module so it can be loaded in the RequireJS test environment.
120genrule(
121 name = "d3-dispatch_requirejs",
122 srcs = [
123 "@npm//:node_modules/d3-dispatch/dist/d3-dispatch.js",
124 ],
125 outs = [
126 "d3-dispatch.js",
127 ],
128 cmd = """echo "define('d3-dispatch', function(require, exports, module) {" > $@ \
129 && cat $< >> $@ \
130 && echo '});' >> $@""",
131)
132
133# Convert d3-timer to an AMD module so it can be loaded in the RequireJS test environment.
134genrule(
135 name = "d3-timer_requirejs",
136 srcs = [
137 "@npm//:node_modules/d3-timer/dist/d3-timer.js",
138 ],
139 outs = [
140 "d3-timer.js",
141 ],
142 cmd = """echo "define('d3-timer', function(require, exports, module) {" > $@ \
143 && cat $< >> $@ \
144 && echo '});' >> $@""",
145)
146
147karma_web_test_suite(
148 name = "test",
149 srcs = [
150 ],
151 # do not sort
152 bootstrap = [
153 "@npm//:node_modules/zone.js/dist/zone-testing-bundle.js",
154 "@npm//:node_modules/reflect-metadata/Reflect.js",
155 ],
156 browsers = [
157 # "@io_bazel_rules_webtesting//browsers:chromium-local",
158 "@io_bazel_rules_webtesting//browsers:firefox-local",
159 ],
160 tags = ["native"],
161 runtime_deps = [
162 "//web/gui2/src/main/webapp:initialize_testbed",
163 ],
164 deps = [
165 ":d3-collection_requirejs",
166 ":d3-dispatch_requirejs",
167 ":d3-force_requirejs",
168 ":d3-quadtree_requirejs",
169 ":d3-timer_requirejs",
170 ":test_lib",
171 ":topojson-client_requirejs",
172 "//web/gui:src/main/webapp/data",
173 "//web/gui2/src/main/webapp:d3_requirejs",
174 "//web/gui2/src/main/webapp:rxjs_umd_modules",
175 ],
176)