/
githubmirror
/
angular-cli
Обзор
Документация
Войти
/
githubmirror
/
angular-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular_devkit/schematics/src/rules/move_spec.ts
80 строк
3 KB
Kristiyan Kostadinov
build: update to TypeScript 6
04 мар 2026, 16:11
04 мар 2026, 16:11
1d7fceb
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ /* eslint-disable @typescript-eslint/no-non-null-assertion */ import { lastValueFrom, of as observableOf } from 'rxjs'; import { SchematicContext } from '../engine/interface'; import { HostTree } from '../tree/host-tree'; import { callRule } from './call'; import { move } from './move'; const context: SchematicContext = null!; describe('move', () => { it('works on moving the whole structure', async () => { const tree = new HostTree(); tree.create('a/b/file1', 'hello world'); tree.create('a/b/file2', 'hello world'); tree.create('a/c/file3', 'hello world'); const result = await lastValueFrom(callRule(move('sub'), observableOf(tree), context)); expect(result.exists('sub/a/b/file1')).toBe(true); expect(result.exists('sub/a/b/file2')).toBe(true); expect(result.exists('sub/a/c/file3')).toBe(true); }); it('works on moving a subdirectory structure', async () => { const tree = new HostTree(); tree.create('a/b/file1', 'hello world'); tree.create('a/b/file2', 'hello world'); tree.create('a/c/file3', 'hello world'); const result = await lastValueFrom(callRule(move('a/b', 'sub'), observableOf(tree), context)); expect(result.exists('sub/file1')).toBe(true); expect(result.exists('sub/file2')).toBe(true); expect(result.exists('a/c/file3')).toBe(true); }); it('works on moving a directory into a subdirectory of itself', async () => { const tree = new HostTree(); tree.create('a/b/file1', 'hello world'); tree.create('a/b/file2', 'hello world'); tree.create('a/c/file3', 'hello world'); const result = await lastValueFrom(callRule(move('a/b', 'a/b/c'), observableOf(tree), context)); expect(result.exists('a/b/c/file1')).toBe(true); expect(result.exists('a/b/c/file2')).toBe(true); expect(result.exists('a/c/file3')).toBe(true); }); it('works on moving a directory into a parent of itself', async () => { const tree = new HostTree(); tree.create('a/b/file1', 'hello world'); tree.create('a/b/file2', 'hello world'); tree.create('a/c/file3', 'hello world'); const result = await lastValueFrom(callRule(move('a/b', 'a'), observableOf(tree), context)); expect(result.exists('file1')).toBe(false); expect(result.exists('file2')).toBe(false); expect(result.exists('a/file1')).toBe(true); expect(result.exists('a/file2')).toBe(true); expect(result.exists('a/c/file3')).toBe(true); }); it('becomes a noop with identical from and to', async () => { const tree = new HostTree(); tree.create('a/b/file1', 'hello world'); tree.create('a/b/file2', 'hello world'); tree.create('a/c/file3', 'hello world'); const result = await lastValueFrom(callRule(move(''), observableOf(tree), context)); expect(result.exists('a/b/file1')).toBe(true); expect(result.exists('a/b/file2')).toBe(true); expect(result.exists('a/c/file3')).toBe(true); }); });