1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
import { CUSTOM_ELEMENTS_SCHEMA, DebugElement } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { MatButtonModule, MatIconModule } from '@angular/material';
import { By } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
// component
import { TargetComponent } from './target.component';
describe('TargetComponent', () => {
let component: TargetComponent;
let fixture: ComponentFixture<TargetComponent>;
let de: DebugElement;
let el: HTMLElement;
beforeEach(
async(() => {
TestBed.configureTestingModule({
imports: [
FormsModule,
BrowserAnimationsModule,
MatButtonModule,
MatIconModule
],
providers: [],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [TargetComponent]
}).compileComponents();
})
);
beforeEach(() => {
// create component and test fixture
fixture = TestBed.createComponent(TargetComponent);
// get test component from the fixture
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
it('should open target tree when click on button', () => {
const openTargetElement = fixture.debugElement
.query(By.css('span[data-tests-id=openTargetTree]'))
.nativeElement.click();
fixture.detectChanges();
const treeContainer = fixture.debugElement.query(
By.css('.filter-container')
);
expect(treeContainer).not.toBeNull();
});
it('should toggle target tree when clicking 2 times on button', () => {
fixture.debugElement
.query(By.css('span[data-tests-id=openTargetTree]'))
.nativeElement.click();
fixture.detectChanges();
fixture.debugElement
.query(By.css('span[data-tests-id=openTargetTree]'))
.nativeElement.click();
fixture.detectChanges();
const treeContainer = fixture.debugElement.query(
By.css('.filter-container')
);
expect(treeContainer).toBeNull();
});
// it('check when input change', () => { tree.setData({nodes: _nodes, options:
// null, events: null}); component.filterFn('liav', tree); });
});
|