|
|
|
|
@ -1,16 +1,9 @@
|
|
|
|
|
import {
|
|
|
|
|
Component,
|
|
|
|
|
ComponentRef,
|
|
|
|
|
EmbeddedViewRef,
|
|
|
|
|
TemplateRef,
|
|
|
|
|
ViewChild,
|
|
|
|
|
ViewContainerRef,
|
|
|
|
|
} from '@angular/core';
|
|
|
|
|
import { Component, ComponentRef, EmbeddedViewRef, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core';
|
|
|
|
|
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';
|
|
|
|
|
import {
|
|
|
|
|
ComponentProjectionStrategy,
|
|
|
|
|
ContainerStrategy,
|
|
|
|
|
CONTAINER_STRATEGY,
|
|
|
|
|
ContainerStrategy,
|
|
|
|
|
CONTEXT_STRATEGY,
|
|
|
|
|
DOM_STRATEGY,
|
|
|
|
|
PROJECTION_STRATEGY,
|
|
|
|
|
@ -57,7 +50,7 @@ describe('ComponentProjectionStrategy', () => {
|
|
|
|
|
describe('#injectContent', () => {
|
|
|
|
|
it('should should insert content into container and return a ComponentRef', () => {
|
|
|
|
|
const strategy = new ComponentProjectionStrategy(TestComponent, containerStrategy);
|
|
|
|
|
componentRef = strategy.injectContent({ get: spectator.inject });
|
|
|
|
|
componentRef = strategy.injectContent({ get: val => spectator.inject(val) });
|
|
|
|
|
spectator.detectChanges();
|
|
|
|
|
|
|
|
|
|
const div = spectator.query('div.foo');
|
|
|
|
|
@ -72,7 +65,7 @@ describe('ComponentProjectionStrategy', () => {
|
|
|
|
|
containerStrategy,
|
|
|
|
|
contextStrategy,
|
|
|
|
|
);
|
|
|
|
|
componentRef = strategy.injectContent({ get: spectator.inject });
|
|
|
|
|
componentRef = strategy.injectContent({ get: val => spectator.inject(val) });
|
|
|
|
|
spectator.detectChanges();
|
|
|
|
|
|
|
|
|
|
const div = spectator.query('div.foo');
|
|
|
|
|
@ -114,7 +107,7 @@ describe('RootComponentProjectionStrategy', () => {
|
|
|
|
|
describe('#injectContent', () => {
|
|
|
|
|
it('should should insert content into body and return a ComponentRef', () => {
|
|
|
|
|
const strategy = new RootComponentProjectionStrategy(TestComponent);
|
|
|
|
|
componentRef = strategy.injectContent({ get: spectator.inject });
|
|
|
|
|
componentRef = strategy.injectContent({ get: val => spectator.inject(val) });
|
|
|
|
|
spectator.detectChanges();
|
|
|
|
|
|
|
|
|
|
const div = document.querySelector('body > ng-component > div.foo');
|
|
|
|
|
@ -127,7 +120,7 @@ describe('RootComponentProjectionStrategy', () => {
|
|
|
|
|
it('should be able to map context to projected component', () => {
|
|
|
|
|
const contextStrategy = CONTEXT_STRATEGY.Component({ bar: 'bar' });
|
|
|
|
|
const strategy = new RootComponentProjectionStrategy(TestComponent, contextStrategy);
|
|
|
|
|
componentRef = strategy.injectContent({ get: spectator.inject });
|
|
|
|
|
componentRef = strategy.injectContent({ get: val => spectator.inject(val) });
|
|
|
|
|
spectator.detectChanges();
|
|
|
|
|
|
|
|
|
|
const div = document.querySelector('body > ng-component > div.foo');
|
|
|
|
|
|