mirror of https://github.com/goharbor/harbor.git
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
import { VulnerabilitySummary } from '../service/index';
|
|
|
|
import { ResultTipComponent } from './result-tip.component';
|
|
import { SharedModule } from '../shared/shared.module';
|
|
|
|
import { SERVICE_CONFIG, IServiceConfig } from '../service.config';
|
|
import { VULNERABILITY_SCAN_STATUS } from '../utils';
|
|
import { UserPermissionService, UserPermissionDefaultService } from "../service/permission.service";
|
|
|
|
describe('ResultTipComponent (inline template)', () => {
|
|
let component: ResultTipComponent;
|
|
let fixture: ComponentFixture<ResultTipComponent>;
|
|
let testConfig: IServiceConfig = {
|
|
vulnerabilityScanningBaseEndpoint: "/api/vulnerability/testing"
|
|
};
|
|
let mockData: VulnerabilitySummary = {
|
|
scan_status: VULNERABILITY_SCAN_STATUS.SUCCESS,
|
|
severity: "High",
|
|
end_time: new Date(),
|
|
summary: {
|
|
total: 124,
|
|
summary: {
|
|
"High": 5,
|
|
"Low": 5
|
|
}
|
|
}
|
|
};
|
|
|
|
beforeEach(async(() => {
|
|
TestBed.configureTestingModule({
|
|
imports: [
|
|
SharedModule
|
|
],
|
|
declarations: [ResultTipComponent],
|
|
providers: [{ provide: SERVICE_CONFIG, useValue: testConfig },
|
|
{ provide: UserPermissionService, useClass: UserPermissionDefaultService }]
|
|
});
|
|
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
fixture = TestBed.createComponent(ResultTipComponent);
|
|
component = fixture.componentInstance;
|
|
component.summary = mockData;
|
|
|
|
fixture.detectChanges();
|
|
});
|
|
|
|
it('should be created', () => {
|
|
expect(component).toBeTruthy();
|
|
});
|
|
|
|
it('should reader the bar with different width', async(() => {
|
|
fixture.detectChanges();
|
|
fixture.whenStable().then(() => {
|
|
fixture.detectChanges();
|
|
let el: HTMLElement = fixture.nativeElement.querySelector('.bar-block-none');
|
|
expect(el).not.toBeNull();
|
|
expect(el.style.width).toEqual("0px");
|
|
let el2: HTMLElement = fixture.nativeElement.querySelector('.bar-block-high');
|
|
expect(el2).not.toBeNull();
|
|
expect(el2.style.width).toEqual("0px");
|
|
});
|
|
}));
|
|
|
|
});
|