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