]> git.apps.os.sepia.ceph.com Git - ceph.git/blob
be6aa09182ca62b224098a0612eff545c3b14dd1
[ceph.git] /
1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3
4 import { of } from 'rxjs';
5
6 import { RgwBucketService } from '~/app/shared/api/rgw-bucket.service';
7 import { CdTableSelection } from '~/app/shared/models/cd-table-selection';
8 import { SharedModule } from '~/app/shared/shared.module';
9 import { configureTestBed } from '~/testing/unit-test-helper';
10 import { RgwBucketDetailsComponent } from './rgw-bucket-details.component';
11 import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
12
13 describe('RgwBucketDetailsComponent', () => {
14   let component: RgwBucketDetailsComponent;
15   let fixture: ComponentFixture<RgwBucketDetailsComponent>;
16   let rgwBucketService: RgwBucketService;
17   let rgwBucketServiceGetSpy: jasmine.Spy;
18
19   configureTestBed({
20     declarations: [RgwBucketDetailsComponent],
21     imports: [SharedModule, HttpClientTestingModule, NgbNavModule]
22   });
23
24   beforeEach(() => {
25     rgwBucketService = TestBed.inject(RgwBucketService);
26     rgwBucketServiceGetSpy = spyOn(rgwBucketService, 'get');
27     rgwBucketServiceGetSpy.and.returnValue(of(null));
28     fixture = TestBed.createComponent(RgwBucketDetailsComponent);
29     component = fixture.componentInstance;
30     component.selection = new CdTableSelection();
31     component.selection = { bid: 'bucket', bucket_quota: { enabled: false, max_size: 0 } };
32     fixture.detectChanges();
33   });
34
35   it('should create', () => {
36     expect(component).toBeTruthy();
37   });
38
39   it('should retrieve bucket full info', () => {
40     component.selection = { bid: 'bucket' };
41     component.ngOnChanges();
42     expect(rgwBucketServiceGetSpy).toHaveBeenCalled();
43   });
44 });