Sean Condon | 436c60a | 2021-01-01 14:23:29 +0000 | [diff] [blame] | 1 | load("@npm//@bazel/typescript:index.bzl", "ts_library") |
| 2 | load("@npm//@bazel/karma:index.bzl", "karma_web_test") |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 3 | |
| 4 | package(default_visibility = ["//:__subpackages__"]) |
| 5 | |
| 6 | # We don't import from these, but the generated ngfactory code will |
| 7 | NG_FACTORY_ADDED_IMPORTS = [ |
| 8 | "@npm//@angular/animations", |
| 9 | "@npm//@angular/forms", |
| 10 | ] |
| 11 | |
Sean Condon | 436c60a | 2021-01-01 14:23:29 +0000 | [diff] [blame] | 12 | ts_library( |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 13 | name = "gui2-topo-lib", |
| 14 | srcs = glob( |
| 15 | include = ["**/*.ts"], |
| 16 | exclude = [ |
| 17 | "**/*.spec.ts", |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 18 | ], |
| 19 | ), |
Sean Condon | 436c60a | 2021-01-01 14:23:29 +0000 | [diff] [blame] | 20 | angular_assets = [ |
| 21 | "//web/gui2-fw-lib:extra_css", |
| 22 | ] + glob([ |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 23 | "**/*.css", |
| 24 | "**/*.html", |
| 25 | ]), |
Sean Condon | a3ad779 | 2020-01-04 19:26:34 +0000 | [diff] [blame] | 26 | tsconfig = "//web/gui2:tsconfig.json", |
Sean Condon | 436c60a | 2021-01-01 14:23:29 +0000 | [diff] [blame] | 27 | use_angular_plugin = True, |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 28 | deps = NG_FACTORY_ADDED_IMPORTS + [ |
| 29 | "//web/gui2-fw-lib", |
| 30 | "@npm//@angular/core", |
Sean Condon | 436c60a | 2021-01-01 14:23:29 +0000 | [diff] [blame] | 31 | "@npm//@angular/common", |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 32 | "@npm//@angular/router", |
| 33 | "@npm//@angular/platform-browser", |
| 34 | "@npm//rxjs", |
| 35 | "@npm//@types", |
| 36 | "@npm//topojson-client", |
| 37 | ], |
| 38 | ) |
Sean Condon | a3ad779 | 2020-01-04 19:26:34 +0000 | [diff] [blame] | 39 | |
| 40 | ts_library( |
| 41 | name = "test_lib", |
| 42 | testonly = 1, |
| 43 | srcs = glob( |
| 44 | include = ["**/*.spec.ts"], |
| 45 | # TODO re-enable this test |
| 46 | exclude = [ |
| 47 | "lib/layer/backgroundsvg/backgroundsvg.component.spec.ts", |
| 48 | "lib/layer/forcesvg/forcesvg.component.spec.ts", |
Sean Condon | f9ff66a | 2020-03-23 08:40:55 +0000 | [diff] [blame] | 49 | "lib/layer/forcesvg/visuals/hostnodesvg/hostnodesvg.component.spec.ts", |
Sean Condon | a3ad779 | 2020-01-04 19:26:34 +0000 | [diff] [blame] | 50 | ], |
| 51 | ), |
| 52 | tsconfig = "//web/gui2:tsconfig-test", |
| 53 | deps = [ |
| 54 | ":gui2-topo-lib", |
| 55 | "//web/gui2-fw-lib", |
| 56 | "@npm//@angular/common", |
| 57 | "@npm//@angular/core", |
| 58 | "@npm//@angular/forms", |
Sean Condon | a3ad779 | 2020-01-04 19:26:34 +0000 | [diff] [blame] | 59 | "@npm//@angular/platform-browser", |
| 60 | "@npm//@angular/router", |
| 61 | "@npm//@types/jasmine", |
| 62 | "@npm//rxjs", |
| 63 | ], |
| 64 | ) |
| 65 | |
| 66 | # Convert topojson-client to an AMD module so it can be loaded in the RequireJS test environment. |
| 67 | genrule( |
| 68 | name = "topojson-client_requirejs", |
| 69 | srcs = [ |
| 70 | "@npm//:node_modules/topojson-client/dist/topojson-client.js", |
| 71 | ], |
| 72 | outs = [ |
| 73 | "topojson-client.js", |
| 74 | ], |
| 75 | cmd = """echo "define('topojson-client', function(require, exports, module) {" > $@ \ |
| 76 | && cat $< >> $@ \ |
| 77 | && echo '});' >> $@""", |
| 78 | ) |
| 79 | |
| 80 | # Convert d3-force to an AMD module so it can be loaded in the RequireJS test environment. |
| 81 | genrule( |
| 82 | name = "d3-force_requirejs", |
| 83 | srcs = [ |
| 84 | "@npm//:node_modules/d3-force/dist/d3-force.js", |
| 85 | ], |
| 86 | outs = [ |
| 87 | "d3-force.js", |
| 88 | ], |
| 89 | cmd = """echo "define('d3-force', function(require, exports, module) {" > $@ \ |
| 90 | && cat $< >> $@ \ |
| 91 | && echo '});' >> $@""", |
| 92 | ) |
| 93 | |
| 94 | # Convert d3-quadtree to an AMD module so it can be loaded in the RequireJS test environment. |
| 95 | genrule( |
| 96 | name = "d3-quadtree_requirejs", |
| 97 | srcs = [ |
| 98 | "@npm//:node_modules/d3-quadtree/dist/d3-quadtree.js", |
| 99 | ], |
| 100 | outs = [ |
| 101 | "d3-quadtree.js", |
| 102 | ], |
| 103 | cmd = """echo "define('d3-quadtree', function(require, exports, module) {" > $@ \ |
| 104 | && cat $< >> $@ \ |
| 105 | && echo '});' >> $@""", |
| 106 | ) |
| 107 | |
| 108 | # Convert d3-collection to an AMD module so it can be loaded in the RequireJS test environment. |
| 109 | genrule( |
| 110 | name = "d3-collection_requirejs", |
| 111 | srcs = [ |
| 112 | "@npm//:node_modules/d3-collection/dist/d3-collection.js", |
| 113 | ], |
| 114 | outs = [ |
| 115 | "d3-collection.js", |
| 116 | ], |
| 117 | cmd = """echo "define('d3-collection', function(require, exports, module) {" > $@ \ |
| 118 | && cat $< >> $@ \ |
| 119 | && echo '});' >> $@""", |
| 120 | ) |
| 121 | |
| 122 | # Convert d3-dispatch to an AMD module so it can be loaded in the RequireJS test environment. |
| 123 | genrule( |
| 124 | name = "d3-dispatch_requirejs", |
| 125 | srcs = [ |
| 126 | "@npm//:node_modules/d3-dispatch/dist/d3-dispatch.js", |
| 127 | ], |
| 128 | outs = [ |
| 129 | "d3-dispatch.js", |
| 130 | ], |
| 131 | cmd = """echo "define('d3-dispatch', function(require, exports, module) {" > $@ \ |
| 132 | && cat $< >> $@ \ |
| 133 | && echo '});' >> $@""", |
| 134 | ) |
| 135 | |
| 136 | # Convert d3-timer to an AMD module so it can be loaded in the RequireJS test environment. |
| 137 | genrule( |
| 138 | name = "d3-timer_requirejs", |
| 139 | srcs = [ |
| 140 | "@npm//:node_modules/d3-timer/dist/d3-timer.js", |
| 141 | ], |
| 142 | outs = [ |
| 143 | "d3-timer.js", |
| 144 | ], |
| 145 | cmd = """echo "define('d3-timer', function(require, exports, module) {" > $@ \ |
| 146 | && cat $< >> $@ \ |
| 147 | && echo '});' >> $@""", |
| 148 | ) |
| 149 | |
Sean Condon | e4e8f6a | 2020-04-13 10:30:35 +0100 | [diff] [blame] | 150 | karma_web_test( |
Sean Condon | f86cfc9 | 2020-04-14 15:10:03 +0100 | [diff] [blame] | 151 | name = "test-not-coverage", # coverage is to avoid being picked up by 'ot' alias |
Sean Condon | a3ad779 | 2020-01-04 19:26:34 +0000 | [diff] [blame] | 152 | srcs = [ |
| 153 | ], |
| 154 | # do not sort |
| 155 | bootstrap = [ |
| 156 | "@npm//:node_modules/zone.js/dist/zone-testing-bundle.js", |
| 157 | "@npm//:node_modules/reflect-metadata/Reflect.js", |
| 158 | ], |
Sean Condon | f86cfc9 | 2020-04-14 15:10:03 +0100 | [diff] [blame] | 159 | config_file = "//web/gui2/src/main/webapp:karma.conf.js", |
Sean Condon | a3ad779 | 2020-01-04 19:26:34 +0000 | [diff] [blame] | 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", |
Sean Condon | f86cfc9 | 2020-04-14 15:10:03 +0100 | [diff] [blame] | 175 | "@npm//@angular-devkit/build-angular", |
| 176 | "@npm//karma-coverage-istanbul-reporter", |
| 177 | "@npm//karma-jasmine-html-reporter", |
Sean Condon | a3ad779 | 2020-01-04 19:26:34 +0000 | [diff] [blame] | 178 | ], |
| 179 | ) |