Skip to content

Commit 4700c5d

Browse files
devversionalan-agius4
authored andcommitted
build: migrate @angular-devkit/schematics tests to rules_js
Migrates `@angular-devkit/schematics` jasmine rules to the native `rules_js` variant. As part of this commit, we are performing a few adjustments that we've discussed as preparation for this migration: - cross package imports are always using the module name - inside package imports are always using relative imports, matching existing tests, fixing a few outliers.
1 parent c9bf07d commit 4700c5d

File tree

8 files changed

+17
-18
lines changed

8 files changed

+17
-18
lines changed

Diff for: goldens/public-api/angular_devkit/schematics/tools/index.api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import { Observable } from 'rxjs';
1212
import { Path } from '@angular-devkit/core';
1313
import { PathFragment } from '@angular-devkit/core';
1414
import { schema } from '@angular-devkit/core';
15+
import { Subject } from 'rxjs';
1516
import { Url } from 'url';
1617
import { virtualFs } from '@angular-devkit/core';
17-
import { workflow } from '@angular-devkit/schematics';
1818

1919
// @public (undocumented)
2020
export class CollectionCannotBeResolvedException extends BaseException {

Diff for: packages/angular_devkit/schematics/BUILD.bazel

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
2-
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
3-
load("//tools:defaults2.bzl", "npm_package", "ts_project")
2+
load("@npm2//:defs.bzl", "npm_link_all_packages")
3+
load("//tools:defaults2.bzl", "jasmine_test", "npm_package", "ts_project")
44

55
# Copyright Google Inc. All Rights Reserved.
66
#
@@ -10,6 +10,8 @@ package(default_visibility = ["//visibility:public"])
1010

1111
licenses(["notice"])
1212

13+
npm_link_all_packages()
14+
1315
# @angular-devkit/schematics
1416

1517
ts_project(
@@ -25,12 +27,11 @@ ts_project(
2527
],
2628
module_name = "@angular-devkit/schematics",
2729
deps = [
30+
":node_modules/@angular-devkit/core",
2831
"//:node_modules/@types/node",
2932
"//:node_modules/jsonc-parser",
3033
"//:node_modules/magic-string",
3134
"//:node_modules/rxjs",
32-
"//packages/angular_devkit/core:core_rjs",
33-
"//packages/angular_devkit/core/node:node_rjs", # TODO: get rid of this for 6.0
3435
],
3536
)
3637

@@ -39,18 +40,17 @@ ts_project(
3940
testonly = True,
4041
srcs = glob(["src/**/*_spec.ts"]),
4142
deps = [
43+
":node_modules/@angular-devkit/core",
4244
":schematics",
4345
"//:node_modules/@types/jasmine",
4446
"//:node_modules/rxjs",
45-
"//packages/angular_devkit/core:core_rjs",
46-
"//packages/angular_devkit/core/node:node_rjs",
4747
"//packages/angular_devkit/schematics/testing:testing_rjs",
4848
],
4949
)
5050

51-
jasmine_node_test(
51+
jasmine_test(
5252
name = "schematics_test",
53-
deps = [":schematics_test_lib"],
53+
data = [":schematics_test_lib_rjs"],
5454
)
5555

5656
genrule(

Diff for: packages/angular_devkit/schematics/src/rules/base_spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
/* eslint-disable @typescript-eslint/no-non-null-assertion */
1010
import { Path, virtualFs } from '@angular-devkit/core';
11-
import { HostTree, MergeStrategy, partitionApplyMerge } from '@angular-devkit/schematics';
1211
import { lastValueFrom, of as observableOf } from 'rxjs';
1312
import { Rule, SchematicContext, Source } from '../engine/interface';
14-
import { Tree } from '../tree/interface';
13+
import { HostTree } from '../tree/host-tree';
14+
import { MergeStrategy, Tree } from '../tree/interface';
1515
import { empty } from '../tree/static';
16-
import { apply, applyToSubtree, chain } from './base';
16+
import { apply, applyToSubtree, chain, partitionApplyMerge } from './base';
1717
import { callRule, callSource } from './call';
1818
import { move } from './move';
1919

Diff for: packages/angular_devkit/schematics/src/rules/call_spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88

99
/* eslint-disable @typescript-eslint/no-non-null-assertion */
1010
/* eslint-disable @typescript-eslint/no-explicit-any */
11-
import { MergeStrategy } from '@angular-devkit/schematics';
1211
import { of as observableOf } from 'rxjs';
1312
import { Rule, SchematicContext, Source } from '../engine/interface';
14-
import { Tree } from '../tree/interface';
13+
import { MergeStrategy, Tree } from '../tree/interface';
1514
import { empty } from '../tree/static';
1615
import {
1716
InvalidRuleResultException,

Diff for: packages/angular_devkit/schematics/src/rules/template_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
/* eslint-disable import/no-extraneous-dependencies */
1010
import { normalize } from '@angular-devkit/core';
11-
import { UnitTestTree } from '@angular-devkit/schematics/testing';
1211
import { of as observableOf } from 'rxjs';
12+
import { UnitTestTree } from '../../testing';
1313
import { SchematicContext } from '../engine/interface';
1414
import { HostTree } from '../tree/host-tree';
1515
import { FileEntry, MergeStrategy } from '../tree/interface';

Diff for: packages/angular_devkit/schematics/src/sink/host_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import { normalize, virtualFs } from '@angular-devkit/core';
10-
import { HostSink } from '@angular-devkit/schematics';
1110
import { HostCreateTree, HostTree } from '../tree/host-tree';
11+
import { HostSink } from './host';
1212

1313
describe('FileSystemSink', () => {
1414
it('works', (done) => {

Diff for: packages/angular_devkit/schematics/tools/file-system-utility.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*/
88

99
import { JsonValue } from '@angular-devkit/core';
10-
import { FileDoesNotExistException } from '@angular-devkit/schematics';
1110
import { readFileSync } from 'fs';
1211
import { ParseError, parse, printParseErrorCode } from 'jsonc-parser';
12+
import { FileDoesNotExistException } from '../src/exception/exception';
1313

1414
export function readJsonFile(path: string): JsonValue {
1515
let data;

Diff for: packages/angular_devkit/schematics/tools/workflow/node-workflow.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import { Path, getSystemPath, normalize, schema, virtualFs } from '@angular-devkit/core';
1010
import { NodeJsSyncHost } from '@angular-devkit/core/node';
11-
import { workflow } from '@angular-devkit/schematics';
11+
import { workflow } from '../../src';
1212
import { BuiltinTaskExecutor } from '../../tasks/node';
1313
import { FileSystemEngine } from '../description';
1414
import { OptionTransform } from '../file-system-engine-host-base';

0 commit comments

Comments
 (0)