/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/elements/test/create-custom-element-env_spec.ts
47 строк
1 KB
Kristiyan Kostadinov
refactor: clean up explicit standalone flags from tests (#63963)
22 сен 2025, 17:27
22 сен 2025, 17:27
f5b50ec
Код
Авторство
О чём код?
/** * @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 {Component} from '@angular/core'; import {createApplication} from '@angular/platform-browser'; import {createCustomElement} from '../public_api'; describe('createCustomElement with env injector', () => { let testContainer: HTMLDivElement; beforeEach(() => { testContainer = document.createElement('div'); document.body.appendChild(testContainer); }); afterEach(() => { testContainer.remove(); (testContainer as any) = null; }); it('should use provided EnvironmentInjector to create a custom element', async () => { @Component({ template: `Hello, standalone element!`, }) class TestStandaloneCmp {} const appRef = await createApplication(); try { const NgElementCtor = createCustomElement(TestStandaloneCmp, {injector: appRef.injector}); customElements.define('test-standalone-cmp', NgElementCtor); const customEl = document.createElement('test-standalone-cmp'); testContainer.appendChild(customEl); expect(testContainer.innerText).toBe('Hello, standalone element!'); } finally { appRef.destroy(); } }); });