• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import {Component, NO_ERRORS_SCHEMA, ViewChild} from '@angular/core';
17import {ComponentFixture, ComponentFixtureAutoDetect, TestBed} from '@angular/core/testing';
18import {TreeNodeComponent} from './tree_node_component';
19
20describe('TreeNodeComponent', () => {
21  let fixture: ComponentFixture<TestHostComponent>;
22  let component: TestHostComponent;
23  let htmlElement: HTMLElement;
24
25  beforeAll(async () => {
26    await TestBed.configureTestingModule({
27      providers: [{provide: ComponentFixtureAutoDetect, useValue: true}],
28      declarations: [TreeNodeComponent, TestHostComponent],
29      schemas: [NO_ERRORS_SCHEMA],
30    }).compileComponents();
31  });
32
33  beforeEach(() => {
34    fixture = TestBed.createComponent(TestHostComponent);
35    component = fixture.componentInstance;
36    htmlElement = fixture.nativeElement;
37  });
38
39  it('can be created', () => {
40    fixture.detectChanges();
41    expect(component).toBeTruthy();
42  });
43
44  @Component({
45    selector: 'host-component',
46    template: `
47      <tree-node
48        [item]="item"
49        [isCollapsed]="true"
50        [isPinned]="false"
51        [isInPinnedSection]="false"
52        [hasChildren]="false"></tree-node>
53    `,
54  })
55  class TestHostComponent {
56    item = {
57      simplifyNames: false,
58      kind: 'entry',
59      name: 'LayerTraceEntry',
60      shortName: 'LTE',
61      chips: [],
62    };
63
64    @ViewChild(TreeNodeComponent)
65    treeNodeComponent!: TreeNodeComponent;
66  }
67});
68