Skip to content

Commit ac85230

Browse files
devversionmmalerba
authored andcommitted
build: run moment adapter tests with bazel (#14687)
1 parent d22f48c commit ac85230

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/material-moment-adapter/BUILD.bazel

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package(default_visibility=["//visibility:public"])
22

3-
load("//tools:defaults.bzl", "ng_module", "ng_package")
3+
load("//tools:defaults.bzl", "ng_module", "ng_package", "ng_web_test_suite", "ng_test_library")
44
load("//:packages.bzl", "ROLLUP_GLOBALS")
55

66
ng_module(
@@ -11,14 +11,37 @@ ng_module(
1111
"@angular//packages/core",
1212
"@matdeps//moment",
1313
"//src/lib/core",
14-
"//src/lib/testing",
1514
],
1615
# Explicitly specify the tsconfig that is also used by Gulp. We need to explicitly use this
1716
# tsconfig because in order to import Moment with TypeScript, we need some special options
1817
# enabled.
1918
tsconfig = ":tsconfig-build.json",
2019
)
2120

21+
ng_test_library(
22+
name = "moment_adapter_test_sources",
23+
srcs = glob(["**/*.spec.ts"]),
24+
deps = [
25+
"//src/lib/core",
26+
"//src/lib/testing",
27+
"@matdeps//moment",
28+
":material-moment-adapter",
29+
],
30+
)
31+
32+
ng_web_test_suite(
33+
name = "unit_tests",
34+
deps = [
35+
":require-config.js",
36+
":moment_adapter_test_sources"
37+
],
38+
# We need to load Moment statically since it is not a named AMD module and needs to
39+
# be manually configured through "require.js" which is used by "ts_web_test_suite".
40+
static_files = [
41+
"@matdeps//moment",
42+
],
43+
)
44+
2245
ng_package(
2346
name = "npm_package",
2447
srcs = ["package.json"],
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Require.js is being used by the karma bazel rules and needs to be configured to properly
2+
// load AMD modules which are not explicitly named in their output bundle.
3+
require.config({
4+
paths: {
5+
'moment': '/base/matdeps/node_modules/moment/min/moment-with-locales.min'
6+
}
7+
});

0 commit comments

Comments
 (0)