Skip to content

Instantly share code, notes, and snippets.

@psamsotha
Last active October 21, 2016 05:21
Show Gist options
  • Select an option

  • Save psamsotha/0bdbeb79bd08bac0e1b9e09e6e4d05a5 to your computer and use it in GitHub Desktop.

Select an option

Save psamsotha/0bdbeb79bd08bac0e1b9e09e6e4d05a5 to your computer and use it in GitHub Desktop.
@Component({
selector: 'p-dataTable',
template: `...`
})
class MockDataTable {
@Input() value;
@Input() selection;
@Output() selectionChange = new EventEmitter();
}
@Component({
selector: 'table-component',
template: '<p-dataTable #table></p-dataTable>'
})
class MyTable {
@ViewChild('table') table;
}
@Component({
template: `
<table-component #myTable></table-component>
`
})
class TestComponent {
@ViewChild('myTable') table;
}
describe('component: TestComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [ ReactiveFormsModule ],
declarations: [ TestComponent, MyTable, MockDataTable ]
});
});
it('should find elements', async(() => {
let fixture = TestBed.createComponent(TestComponent);
let component = fixture.componentInstance;
fixture.detectChanges();
console.log(`DATATABLE: ${component.table.table}`);
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment