summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/components/code-block/code-block.component.spect.ts
blob: bc5ad428fd8a8c929920c4bd129316b2ff784a40 (plain)
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
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CodeBlockComponent } from './code-block.component';
import { configureTestBed } from '~/testing/unit-test-helper';

describe('CodeBlockComponent', () => {
  let component: CodeBlockComponent;
  let fixture: ComponentFixture<CodeBlockComponent>;

  configureTestBed({
    declarations: [CodeBlockComponent]
  });

  beforeEach(() => {
    fixture = TestBed.createComponent(CodeBlockComponent);
    component = fixture.componentInstance;
    component.codes = [];
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });

  it('should show single codeblock if there are only one code', () => {
    component.codes = ['code'];
    fixture.detectChanges();
    expect(fixture.nativeElement.querySelector('#singleCodeBlock')).not.toBeNull();
    expect(fixture.nativeElement.querySelector('#bigCodeBlock')).toBeNull();
  });

  it('should show single codeblock if there are only one code', () => {
    component.codes = ['code1', 'code2'];
    fixture.detectChanges();
    expect(fixture.nativeElement.querySelector('#bigCodeBlock')).not.toBeNull();
    expect(fixture.nativeElement.querySelector('#singleCodeBlock')).toBeNull();
  });
});