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';
10 describe('RgwStorageClassDetailsComponent', () => {
11 let component: RgwStorageClassDetailsComponent;
12 let fixture: ComponentFixture<RgwStorageClassDetailsComponent>;
14 const mockSelection: StorageClassDetails = {
15 access_key: 'TestAccessKey',
17 target_path: '/test/path',
18 multipart_min_part_size: 100,
19 multipart_sync_threshold: 200,
21 retain_head_object: true,
22 allow_read_through: true,
27 beforeEach(async () => {
28 await TestBed.configureTestingModule({
30 BrowserAnimationsModule,
32 HttpClientTestingModule,
35 declarations: [RgwStorageClassDetailsComponent]
36 }).compileComponents();
38 fixture = TestBed.createComponent(RgwStorageClassDetailsComponent);
39 component = fixture.componentInstance;
40 component.selection = mockSelection;
42 fixture.detectChanges();
45 it('should create', () => {
46 expect(component).toBeTruthy();
49 it('should update storageDetails when selection input changes', () => {
50 const newSelection: StorageClassDetails = {
51 access_key: 'NewAccessKey',
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,
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'
68 component.selection = newSelection;
69 component.ngOnChanges({
70 selection: new SimpleChange(null, newSelection, false)
72 expect(component.storageDetails).toEqual(newSelection);