]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / block / rbd-form / rbd-form.component.spec.ts
1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { ReactiveFormsModule } from '@angular/forms';
4 import { ActivatedRoute } from '@angular/router';
5 import { RouterTestingModule } from '@angular/router/testing';
6 import { TooltipModule } from 'ngx-bootstrap/tooltip';
7
8 import { ToastModule } from 'ng2-toastr';
9
10 import { By } from '@angular/platform-browser';
11 import { ActivatedRouteStub } from '../../../../testing/activated-route-stub';
12 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
13 import { RbdService } from '../../../shared/api/rbd.service';
14 import { SharedModule } from '../../../shared/shared.module';
15 import { RbdConfigurationFormComponent } from '../rbd-configuration-form/rbd-configuration-form.component';
16 import { RbdFormMode } from './rbd-form-mode.enum';
17 import { RbdFormComponent } from './rbd-form.component';
18
19 describe('RbdFormComponent', () => {
20 let component: RbdFormComponent;
21 let fixture: ComponentFixture<RbdFormComponent>;
22 let activatedRoute: ActivatedRouteStub;
23
24 configureTestBed({
25 imports: [
26 HttpClientTestingModule,
27 ReactiveFormsModule,
28 RouterTestingModule,
29 ToastModule.forRoot(),
30 SharedModule,
31 TooltipModule
32 ],
33 declarations: [RbdFormComponent, RbdConfigurationFormComponent],
34 providers: [
35 {
36 provide: ActivatedRoute,
37 useValue: new ActivatedRouteStub({ pool: 'foo', name: 'bar', snap: undefined })
38 },
39 i18nProviders
40 ]
41 });
42
43 beforeEach(() => {
44 fixture = TestBed.createComponent(RbdFormComponent);
45 component = fixture.componentInstance;
46 activatedRoute = TestBed.get(ActivatedRoute);
47 });
48
49 it('should create', () => {
50 expect(component).toBeTruthy();
51 });
52
53 describe('should test decodeURIComponent of params', () => {
54 let rbdService: RbdService;
55
56 beforeEach(() => {
57 rbdService = TestBed.get(RbdService);
58 component.mode = RbdFormMode.editing;
59 fixture.detectChanges();
60 spyOn(rbdService, 'get').and.callThrough();
61 });
62
63 it('without snapName', () => {
64 activatedRoute.setParams({ pool: 'foo%2Ffoo', name: 'bar%2Fbar', snap: undefined });
65
66 expect(rbdService.get).toHaveBeenCalledWith('foo/foo', 'bar/bar');
67 expect(component.snapName).toBeUndefined();
68 });
69
70 it('with snapName', () => {
71 activatedRoute.setParams({ pool: 'foo%2Ffoo', name: 'bar%2Fbar', snap: 'baz%2Fbaz' });
72
73 expect(rbdService.get).toHaveBeenCalledWith('foo/foo', 'bar/bar');
74 expect(component.snapName).toBe('baz/baz');
75 });
76 });
77
78 describe('test image configuration component', () => {
79 it('is visible', () => {
80 fixture.detectChanges();
81 expect(
82 fixture.debugElement.query(By.css('cd-rbd-configuration-form')).nativeElement.parentElement
83 .hidden
84 ).toBe(false);
85 });
86 });
87 });