summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/components/code-block/code-block.component.spect.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/app/shared/components/code-block/code-block.component.spect.ts')
-rw-r--r--src/pybind/mgr/dashboard/frontend/src/app/shared/components/code-block/code-block.component.spect.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/code-block/code-block.component.spect.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/code-block/code-block.component.spect.ts
new file mode 100644
index 000000000..bc5ad428f
--- /dev/null
+++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/code-block/code-block.component.spect.ts
@@ -0,0 +1,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();
+ });
+});