Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ describe('component-tree', () => {
describe('getRootElements', () => {
beforeEach(() => {
const ng: Partial<Ng> = {
getComponent: jasmine.createSpy('getComponent').and.returnValue({}),
getComponent: jasmine.createSpy('getComponent').and.callFake((element: HTMLElement) => {
// Will treat only `ng-*` elements as Angular components.
if (element.tagName.toLowerCase().startsWith('ng-')) {
return element;
}
return null;
}),
};
(window as any).ng = ng;
});
Expand Down Expand Up @@ -105,6 +111,21 @@ describe('component-tree', () => {
expect(roots.length).toEqual(1);
expect(roots).toContain(document.body);
});

it('should return all root elements with all non-application root components', () => {
const rootElement = createRoot();
const childElement = createRoot();
const nonAppRootCmp = document.createElement('ng-cmp');

rootElement.appendChild(childElement);
document.body.appendChild(rootElement);
document.body.appendChild(nonAppRootCmp);

const roots = getRootElements();

expect(roots.length).toEqual(2);
expect(roots).toEqual([rootElement, nonAppRootCmp]);
});
});

describe('serializeProviderRecord', () => {
Expand Down
Loading