]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/blob
1321a72c035a75d2a933d32e7f63a3bed6401730
[ceph-ci.git] /
1 import { ComponentFixture, TestBed } from '@angular/core/testing';
2 import { RgwStorageClassDetailsComponent } from './rgw-storage-class-details.component';
3 import { StorageClassDetails } from '../models/rgw-storage-class.model';
4 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
5 import { SharedModule } from '~/app/shared/shared.module';
6 import { HttpClientTestingModule } from '@angular/common/http/testing';
7 import { RouterTestingModule } from '@angular/router/testing';
8 import { SimpleChange } from '@angular/core';
9
10 describe('RgwStorageClassDetailsComponent', () => {
11   let component: RgwStorageClassDetailsComponent;
12   let fixture: ComponentFixture<RgwStorageClassDetailsComponent>;
13
14   const mockSelection: StorageClassDetails = {
15     access_key: 'TestAccessKey',
16     secret: 'TestSecret',
17     target_path: '/test/path',
18     multipart_min_part_size: 100,
19     multipart_sync_threshold: 200,
20     host_style: 'path',
21     retain_head_object: true,
22     allow_read_through: true,
23     tier_type: 'local',
24     acl_mappings: []
25   };
26
27   beforeEach(async () => {
28     await TestBed.configureTestingModule({
29       imports: [
30         BrowserAnimationsModule,
31         SharedModule,
32         HttpClientTestingModule,
33         RouterTestingModule
34       ],
35       declarations: [RgwStorageClassDetailsComponent]
36     }).compileComponents();
37
38     fixture = TestBed.createComponent(RgwStorageClassDetailsComponent);
39     component = fixture.componentInstance;
40     component.selection = mockSelection;
41
42     fixture.detectChanges();
43   });
44
45   it('should create', () => {
46     expect(component).toBeTruthy();
47   });
48
49   it('should update storageDetails when selection input changes', () => {
50     const newSelection: StorageClassDetails = {
51       access_key: 'NewAccessKey',
52       secret: 'NewSecret',
53       target_path: '/new/path',
54       multipart_min_part_size: 500,
55       multipart_sync_threshold: 1000,
56       host_style: 'virtual',
57       retain_head_object: false,
58       allow_read_through: false,
59       tier_type: 'archive',
60       glacier_restore_days: 1,
61       glacier_restore_tier_type: 'standard',
62       placement_targets: '',
63       read_through_restore_days: 7,
64       restore_storage_class: 'restored',
65       zonegroup_name: 'zone1'
66     };
67
68     component.selection = newSelection;
69     component.ngOnChanges({
70       selection: new SimpleChange(null, newSelection, false)
71     });
72     expect(component.storageDetails).toEqual(newSelection);
73   });
74 });