]> git.apps.os.sepia.ceph.com Git - ceph.git/blob
d5d302bf0224b1e6da5ebd4453bb10b34467179f
[ceph.git] /
1 import { ComponentFixture, TestBed } from '@angular/core/testing';
2
3 import { SmbClusterTabsComponent } from './smb-cluster-tabs.component';
4 import { RESOURCE_TYPE, SMBCluster } from '../smb.model';
5 import { By } from '@angular/platform-browser';
6
7 describe('SmbClusterTabsComponent', () => {
8   let component: SmbClusterTabsComponent;
9   let fixture: ComponentFixture<SmbClusterTabsComponent>;
10
11   beforeEach(async () => {
12     await TestBed.configureTestingModule({
13       declarations: [SmbClusterTabsComponent]
14     }).compileComponents();
15
16     fixture = TestBed.createComponent(SmbClusterTabsComponent);
17     component = fixture.componentInstance;
18     fixture.detectChanges();
19   });
20
21   it('should create', () => {
22     expect(component).toBeTruthy();
23   });
24
25   it('should not render anything if selection is falsy', () => {
26     component.selection = null;
27     fixture.detectChanges();
28
29     const tabsElement = fixture.debugElement.query(By.css('cds-tabs'));
30     expect(tabsElement).toBeNull();
31   });
32
33   const selectedSmbCluster = (clusterId: string) => {
34     const smbCluster: SMBCluster = {
35       resource_type: RESOURCE_TYPE,
36       cluster_id: clusterId,
37       auth_mode: 'user'
38     };
39     return smbCluster;
40   };
41
42   it('should render cds-tabs if selection is truthy', () => {
43     component.selection = selectedSmbCluster('fooBar');
44     fixture.detectChanges();
45
46     const tabsElement = fixture.debugElement.query(By.css('cds-tabs'));
47     expect(tabsElement).toBeTruthy();
48   });
49 });