/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
devtools/projects/ng-devtools-backend/src/lib/directive-forest/component-tree/get-roots.spec.ts
48 строк
1 KB
hawkgs
refactor(devtools): reorganize backend code
20 июл 2026, 12:15
20 июл 2026, 12:15
a7ebf1c
Код
Авторство
О чём код?
/** * @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 */ import {getAppRoots} from './get-roots'; function createRoot() { const root = document.createElement('div'); root.setAttribute('ng-version', ''); return root; } describe('getRoots', () => { afterEach(() => { document.body.replaceChildren(); }); it('should return root element', () => { const rootElement = createRoot(); const childElement = createRoot(); rootElement.appendChild(childElement); document.body.appendChild(rootElement); const roots = getAppRoots(); expect(roots.length).toEqual(1); expect(roots.pop()).toEqual(rootElement); }); it('should return root elements', () => { const firstRoot = createRoot(); const secondRoot = createRoot(); document.body.appendChild(firstRoot); document.body.appendChild(secondRoot); const roots = getAppRoots(); expect(roots.length).toEqual(2); expect(roots).toContain(firstRoot); expect(roots).toContain(secondRoot); }); });