mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
remove the following utilities used in unit tests which check for features that are supported by all supported browsers: - supportsCustomElements - supportsWebAnimation - supportsRegExUnicodeFlag - supportsTemplateElement also remove the following utilities which check for features that are not supported (and aren't going to be) by any of the supported browsers: - supportsDeprecatedCustomCustomElementsV0 - supportsDeprecatedShadowDomV0 PR Close #47543
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
/**
|
|
* @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.io/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(() => {
|
|
document.body.removeChild(testContainer);
|
|
(testContainer as any) = null;
|
|
});
|
|
|
|
it('should use provided EnvironmentInjector to create a custom element', async () => {
|
|
@Component({
|
|
standalone: true,
|
|
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();
|
|
}
|
|
});
|
|
});
|