-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14849 from qmonmert/angular/test-healthmodal
[Angular] Add health-modal test
- Loading branch information
Showing
3 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
...mplates/angular/src/main/webapp/app/admin/health/modal/health-modal.component.spec.ts.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
import { HealthModalComponent } from './health-modal.component'; | ||
|
||
describe('Component Tests', () => { | ||
describe('HealthModalComponent', () => { | ||
let comp: HealthModalComponent; | ||
let fixture: ComponentFixture<HealthModalComponent>; | ||
let mockActiveModal: NgbActiveModal; | ||
|
||
beforeEach( | ||
waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [HttpClientTestingModule], | ||
declarations: [HealthModalComponent], | ||
providers: [NgbActiveModal], | ||
}) | ||
.overrideTemplate(HealthModalComponent, '') | ||
.compileComponents(); | ||
}) | ||
); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(HealthModalComponent); | ||
comp = fixture.componentInstance; | ||
mockActiveModal = TestBed.inject(NgbActiveModal); | ||
}); | ||
|
||
describe('readableValue', () => { | ||
it('should return stringify value', () => { | ||
// GIVEN | ||
comp.health = undefined; | ||
|
||
// WHEN | ||
const result = comp.readableValue({ 'name': 'jhipster' }); | ||
|
||
// THEN | ||
expect(result).toEqual('{"name":"jhipster"}'); | ||
}); | ||
|
||
it('should return string value', () => { | ||
// GIVEN | ||
comp.health = undefined; | ||
|
||
// WHEN | ||
const result = comp.readableValue('jhipster'); | ||
|
||
// THEN | ||
expect(result).toEqual('jhipster'); | ||
}); | ||
|
||
it('should return storage space in an human readable unit (GB)', () => { | ||
// GIVEN | ||
comp.health = { | ||
key: 'diskSpace', | ||
value: { | ||
status: 'UP' | ||
} | ||
}; | ||
|
||
// WHEN | ||
const result = comp.readableValue(1073741825); | ||
|
||
// THEN | ||
expect(result).toEqual('1.00 GB'); | ||
}); | ||
|
||
it('should return storage space in an human readable unit (MB)', () => { | ||
// GIVEN | ||
comp.health = { | ||
key: 'diskSpace', | ||
value: { | ||
status: 'UP' | ||
} | ||
}; | ||
|
||
// WHEN | ||
const result = comp.readableValue(1073741824); | ||
|
||
// THEN | ||
expect(result).toEqual('1024.00 MB'); | ||
}); | ||
|
||
it('should return string value', () => { | ||
// GIVEN | ||
comp.health = { | ||
key: 'mail', | ||
value: { | ||
status: 'UP' | ||
} | ||
}; | ||
|
||
// WHEN | ||
const result = comp.readableValue(1234); | ||
|
||
// THEN | ||
expect(result).toEqual('1234'); | ||
}); | ||
}); | ||
|
||
describe('dismiss', () => { | ||
it('should call dismiss when dismiss modal is called', () => { | ||
// GIVEN | ||
const spy = spyOn(mockActiveModal, 'dismiss').and.callThrough(); | ||
|
||
// WHEN | ||
comp.dismiss(); | ||
|
||
// THEN | ||
expect(spy).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters