2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google Inc. 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
|
|
|
|
|
*/
|
|
|
|
|
|
2016-06-30 13:07:17 -07:00
|
|
|
import './init';
|
|
|
|
|
import {DebugElement, QueryList} from '@angular/core';
|
|
|
|
|
import {By} from '@angular/platform-browser';
|
2016-05-25 14:29:06 -07:00
|
|
|
import {CompForChildQuery, CompWithChildQuery} from '../src/queries';
|
2016-06-30 13:07:17 -07:00
|
|
|
import {createComponent} from './util';
|
2016-05-25 14:29:06 -07:00
|
|
|
|
|
|
|
|
describe('child queries', () => {
|
|
|
|
|
it('should support compiling child queries', () => {
|
2016-06-30 13:07:17 -07:00
|
|
|
var childQueryCompFixture = createComponent(CompWithChildQuery);
|
|
|
|
|
var debugElement = childQueryCompFixture.debugElement;
|
2016-05-25 14:29:06 -07:00
|
|
|
var compWithChildren = debugElement.query(By.directive(CompWithChildQuery));
|
2016-06-30 13:07:17 -07:00
|
|
|
expect(childQueryCompFixture.componentInstance.child).toBeDefined();
|
|
|
|
|
expect(childQueryCompFixture.componentInstance.child instanceof CompForChildQuery).toBe(true);
|
2016-05-25 14:29:06 -07:00
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should support compiling children queries', () => {
|
2016-06-30 13:07:17 -07:00
|
|
|
var childQueryCompFixture = createComponent(CompWithChildQuery);
|
|
|
|
|
var debugElement = childQueryCompFixture.debugElement;
|
2016-05-25 14:29:06 -07:00
|
|
|
var compWithChildren = debugElement.query(By.directive(CompWithChildQuery));
|
|
|
|
|
|
2016-06-30 13:07:17 -07:00
|
|
|
childQueryCompFixture.detectChanges();
|
2016-05-25 14:29:06 -07:00
|
|
|
|
2016-06-30 13:07:17 -07:00
|
|
|
expect(childQueryCompFixture.componentInstance.children).toBeDefined();
|
|
|
|
|
expect(childQueryCompFixture.componentInstance.children instanceof QueryList).toBe(true);
|
2016-05-25 14:29:06 -07:00
|
|
|
});
|
|
|
|
|
});
|