mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 20:02:40 +08:00
test(@angular-devkit/schematics): add bazel tests
This commit is contained in:
parent
a6028a7761
commit
e17cc66f93
@ -5,20 +5,24 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
load("//tools:defaults.bzl", "ts_library")
|
load("//tools:defaults.bzl", "ts_library")
|
||||||
|
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
||||||
|
|
||||||
licenses(["notice"]) # MIT License
|
licenses(["notice"]) # MIT License
|
||||||
|
|
||||||
|
# @angular-devkit/schematics
|
||||||
|
|
||||||
ts_library(
|
ts_library(
|
||||||
name = "schematics",
|
name = "schematics",
|
||||||
srcs = glob(
|
srcs = glob(
|
||||||
include = ["src/**/*.ts"],
|
include = ["src/**/*.ts"],
|
||||||
exclude = [
|
exclude = [
|
||||||
"src/**/*_spec.ts",
|
"src/**/*_spec.ts",
|
||||||
|
"src/**/*_spec_large.ts",
|
||||||
"src/**/*_benchmark.ts",
|
"src/**/*_benchmark.ts",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
module_name = "@angular-devkit/schematics",
|
module_name = "@angular-devkit/schematics",
|
||||||
module_root = "src",
|
module_root = "src/index.d.ts",
|
||||||
deps = [
|
deps = [
|
||||||
"//packages/angular_devkit/core",
|
"//packages/angular_devkit/core",
|
||||||
"//packages/angular_devkit/core:node", # TODO: get rid of this for 6.0
|
"//packages/angular_devkit/core:node", # TODO: get rid of this for 6.0
|
||||||
@ -28,6 +32,39 @@ ts_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ts_library(
|
||||||
|
name = "schematics_test_lib",
|
||||||
|
srcs = glob(
|
||||||
|
include = [
|
||||||
|
"src/**/*_spec.ts",
|
||||||
|
"src/**/*_spec_large.ts",
|
||||||
|
],
|
||||||
|
exclude = [
|
||||||
|
# Instances of extended errors are showing Error as the constructor instead.
|
||||||
|
# TODO(@filipesilva): figure out why that is.
|
||||||
|
"src/rules/call_spec.ts",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
deps = [
|
||||||
|
":schematics",
|
||||||
|
":testing",
|
||||||
|
"//packages/angular_devkit/core",
|
||||||
|
"//packages/angular_devkit/core:node",
|
||||||
|
"@rxjs",
|
||||||
|
"@rxjs//operators",
|
||||||
|
# @typings: jasmine
|
||||||
|
# @typings: node
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
jasmine_node_test(
|
||||||
|
name = "schematics_test",
|
||||||
|
srcs = [":schematics_test_lib"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# @angular-devkit/schematics/tasks
|
||||||
|
|
||||||
ts_library(
|
ts_library(
|
||||||
name = "tasks",
|
name = "tasks",
|
||||||
srcs = glob(
|
srcs = glob(
|
||||||
@ -35,11 +72,11 @@ ts_library(
|
|||||||
exclude = [
|
exclude = [
|
||||||
"tasks/**/*_spec.ts",
|
"tasks/**/*_spec.ts",
|
||||||
"tasks/**/*_benchmark.ts",
|
"tasks/**/*_benchmark.ts",
|
||||||
|
"tasks/tslint-fix/test/**/*",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
module_name = "@angular-devkit/schematics/tasks",
|
module_name = "@angular-devkit/schematics/tasks",
|
||||||
module_root = "tasks",
|
module_root = "tasks/index.d.ts",
|
||||||
tsconfig = "//:tsconfig.json",
|
|
||||||
deps = [
|
deps = [
|
||||||
":schematics",
|
":schematics",
|
||||||
"//packages/angular_devkit/core",
|
"//packages/angular_devkit/core",
|
||||||
@ -52,6 +89,47 @@ ts_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ts_library(
|
||||||
|
name = "tasks_test_lib",
|
||||||
|
srcs = glob(
|
||||||
|
include = [
|
||||||
|
"tasks/**/*_spec.ts",
|
||||||
|
"tasks/**/*_spec_large.ts",
|
||||||
|
"tasks/tslint-fix/test/**/*.ts",
|
||||||
|
],
|
||||||
|
exclude = [
|
||||||
|
# Disabled because 'collection.json' cannot be resolved in bazel.
|
||||||
|
# TODO(@filipesilva): figure out how to make data files resolve correctly.
|
||||||
|
"tasks/tslint-fix/executor_spec.ts",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
data = [
|
||||||
|
"tasks/tslint-fix/test/collection.json",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
":tasks",
|
||||||
|
":testing",
|
||||||
|
":schematics",
|
||||||
|
"//packages/angular_devkit/core",
|
||||||
|
"//packages/angular_devkit/core:node",
|
||||||
|
"//packages/angular_devkit/core:node_testing",
|
||||||
|
"@rxjs",
|
||||||
|
"@rxjs//operators",
|
||||||
|
# @typings: jasmine
|
||||||
|
# @typings: node
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Disabled since we are excluding the only test in tasks.
|
||||||
|
# jasmine_node_test(
|
||||||
|
# name = "tasks_test",
|
||||||
|
# srcs = [":tasks_test_lib"],
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
# @angular-devkit/schematics/tools
|
||||||
|
|
||||||
ts_library(
|
ts_library(
|
||||||
name = "tools",
|
name = "tools",
|
||||||
srcs = glob(
|
srcs = glob(
|
||||||
@ -62,7 +140,7 @@ ts_library(
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
module_name = "@angular-devkit/schematics/tools",
|
module_name = "@angular-devkit/schematics/tools",
|
||||||
module_root = "tools",
|
module_root = "tools/index.d.ts",
|
||||||
deps = [
|
deps = [
|
||||||
":schematics",
|
":schematics",
|
||||||
":tasks",
|
":tasks",
|
||||||
@ -74,6 +152,44 @@ ts_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ts_library(
|
||||||
|
name = "tools_test_lib",
|
||||||
|
srcs = glob(
|
||||||
|
include = [
|
||||||
|
"tools/**/*_spec.ts",
|
||||||
|
"tools/**/*_spec_large.ts",
|
||||||
|
],
|
||||||
|
exclude = [
|
||||||
|
# The node resolve spec uses the _devKitRoot global, which isn't available in Bazel.
|
||||||
|
# TODO(@filipesilva): figure out an alternative to that global.
|
||||||
|
"tools/file-system-engine-host_spec.ts",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
data = glob(
|
||||||
|
include = ["tools/test/file-system-engine-host/**/collection.json"],
|
||||||
|
),
|
||||||
|
deps = [
|
||||||
|
":tools",
|
||||||
|
":tasks",
|
||||||
|
":schematics",
|
||||||
|
":testing",
|
||||||
|
"//packages/angular_devkit/core",
|
||||||
|
"//packages/angular_devkit/core:node",
|
||||||
|
"@rxjs",
|
||||||
|
"@rxjs//operators",
|
||||||
|
# @typings: jasmine
|
||||||
|
# @typings: node
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
jasmine_node_test(
|
||||||
|
name = "tools_test",
|
||||||
|
srcs = [":tools_test_lib"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# @angular-devkit/schematics/testing
|
||||||
|
|
||||||
ts_library(
|
ts_library(
|
||||||
name = "testing",
|
name = "testing",
|
||||||
srcs = glob(
|
srcs = glob(
|
||||||
@ -81,7 +197,7 @@ ts_library(
|
|||||||
exclude = [],
|
exclude = [],
|
||||||
),
|
),
|
||||||
module_name = "@angular-devkit/schematics/testing",
|
module_name = "@angular-devkit/schematics/testing",
|
||||||
module_root = "testing",
|
module_root = "testing/index.d.ts",
|
||||||
deps = [
|
deps = [
|
||||||
":schematics",
|
":schematics",
|
||||||
":tasks",
|
":tasks",
|
||||||
@ -91,35 +207,3 @@ ts_library(
|
|||||||
"@rxjs//operators",
|
"@rxjs//operators",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
ts_library(
|
|
||||||
name = "spec",
|
|
||||||
srcs = glob(
|
|
||||||
include = ["src/**/*_spec.ts"],
|
|
||||||
),
|
|
||||||
deps = [
|
|
||||||
":schematics",
|
|
||||||
":testing",
|
|
||||||
"//packages/angular_devkit/core",
|
|
||||||
"@rxjs",
|
|
||||||
"@rxjs//operators",
|
|
||||||
# @typings: jasmine
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
ts_library(
|
|
||||||
name = "tools_spec",
|
|
||||||
srcs = glob(
|
|
||||||
include = ["tools/**/*_spec.ts"],
|
|
||||||
),
|
|
||||||
deps = [
|
|
||||||
":schematics",
|
|
||||||
":tools",
|
|
||||||
"//packages/angular_devkit/core",
|
|
||||||
"//packages/angular_devkit/core:node",
|
|
||||||
"@rxjs",
|
|
||||||
"@rxjs//operators",
|
|
||||||
# @typings: jasmine
|
|
||||||
# @typings: node
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
// tslint:disable:no-implicit-dependencies
|
// tslint:disable:no-implicit-dependencies
|
||||||
import { normalize, virtualFs } from '@angular-devkit/core';
|
import { normalize, virtualFs } from '@angular-devkit/core';
|
||||||
import { HostSink } from '@angular-devkit/schematics';
|
import { HostSink } from '@angular-devkit/schematics';
|
||||||
import { fileBufferToString } from '../../../core/src/virtual-fs/host';
|
|
||||||
import { HostCreateTree, HostTree } from '../tree/host-tree';
|
import { HostCreateTree, HostTree } from '../tree/host-tree';
|
||||||
import { optimize } from '../tree/static';
|
import { optimize } from '../tree/static';
|
||||||
|
|
||||||
@ -133,7 +132,7 @@ describe('FileSystemSink', () => {
|
|||||||
.toPromise()
|
.toPromise()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
expect(host.sync.read(normalize('/file0')).toString()).toBe('hello');
|
expect(host.sync.read(normalize('/file0')).toString()).toBe('hello');
|
||||||
expect(fileBufferToString(host.sync.read(normalize('/file1')))).toBe('world');
|
expect(virtualFs.fileBufferToString(host.sync.read(normalize('/file1')))).toBe('world');
|
||||||
})
|
})
|
||||||
.then(done, done.fail);
|
.then(done, done.fail);
|
||||||
});
|
});
|
||||||
|
@ -11,12 +11,16 @@ import { ExportStringRef } from './export-ref';
|
|||||||
|
|
||||||
|
|
||||||
describe('ExportStringRef', () => {
|
describe('ExportStringRef', () => {
|
||||||
|
// Depending on how the package is built the module might be either .js or .ts.
|
||||||
|
// To make expectations easier, we strip the extension.
|
||||||
|
const stripExtension = (p: string) => p.replace(/\.(j|t)s$/, '');
|
||||||
|
|
||||||
it('works', () => {
|
it('works', () => {
|
||||||
// META
|
// META
|
||||||
const ref = new ExportStringRef('./export-ref#ExportStringRef', __dirname);
|
const ref = new ExportStringRef('./export-ref#ExportStringRef', __dirname);
|
||||||
expect(ref.ref).toBe(ExportStringRef);
|
expect(ref.ref).toBe(ExportStringRef);
|
||||||
expect(ref.path).toBe(__dirname);
|
expect(ref.path).toBe(__dirname);
|
||||||
expect(ref.module).toBe(path.join(__dirname, 'export-ref.ts'));
|
expect(stripExtension(ref.module)).toBe(path.join(__dirname, 'export-ref'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works without an inner ref', () => {
|
it('works without an inner ref', () => {
|
||||||
@ -24,7 +28,7 @@ describe('ExportStringRef', () => {
|
|||||||
const ref = new ExportStringRef(path.join(__dirname, 'export-ref'));
|
const ref = new ExportStringRef(path.join(__dirname, 'export-ref'));
|
||||||
expect(ref.ref).toBe(undefined);
|
expect(ref.ref).toBe(undefined);
|
||||||
expect(ref.path).toBe(__dirname);
|
expect(ref.path).toBe(__dirname);
|
||||||
expect(ref.module).toBe(path.join(__dirname, 'export-ref.ts'));
|
expect(stripExtension(ref.module)).toBe(path.join(__dirname, 'export-ref'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the exports', () => {
|
it('returns the exports', () => {
|
||||||
@ -32,7 +36,7 @@ describe('ExportStringRef', () => {
|
|||||||
const ref = new ExportStringRef('./export-ref#ExportStringRef', __dirname, false);
|
const ref = new ExportStringRef('./export-ref#ExportStringRef', __dirname, false);
|
||||||
expect(ref.ref).toEqual({ ExportStringRef });
|
expect(ref.ref).toEqual({ ExportStringRef });
|
||||||
expect(ref.path).toBe(__dirname);
|
expect(ref.path).toBe(__dirname);
|
||||||
expect(ref.module).toBe(path.join(__dirname, 'export-ref.ts'));
|
expect(stripExtension(ref.module)).toBe(path.join(__dirname, 'export-ref'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works on package names', () => {
|
it('works on package names', () => {
|
||||||
@ -42,13 +46,13 @@ describe('ExportStringRef', () => {
|
|||||||
);
|
);
|
||||||
expect(ref.ref).toEqual(CollectionCannotBeResolvedException);
|
expect(ref.ref).toEqual(CollectionCannotBeResolvedException);
|
||||||
expect(ref.path).toBe(__dirname);
|
expect(ref.path).toBe(__dirname);
|
||||||
expect(ref.module).toBe(path.join(__dirname, 'index.ts'));
|
expect(stripExtension(ref.module)).toBe(path.join(__dirname, 'index'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works on directory', () => {
|
it('works on directory', () => {
|
||||||
// META
|
// META
|
||||||
const ref = new ExportStringRef(__dirname);
|
const ref = new ExportStringRef(__dirname);
|
||||||
expect(ref.path).toBe(__dirname);
|
expect(ref.path).toBe(__dirname);
|
||||||
expect(ref.module).toBe(path.join(__dirname, 'index.ts'));
|
expect(stripExtension(ref.module)).toBe(path.join(__dirname, 'index'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user