Updated unit tests
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
df94190a8c
commit
0ce782a4de
|
@ -4,15 +4,15 @@ describe('Client', () => {
|
|||
describe('Component vnClientSummary', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
let $scope;
|
||||
let $window;
|
||||
|
||||
beforeEach(ngModule('client'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
|
||||
beforeEach(inject(($componentController, _$httpBackend_, _$window_) => {
|
||||
$window = _$window_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
$scope = $rootScope.$new();
|
||||
const $element = angular.element('<vn-client-summary></vn-client-summary>');
|
||||
controller = $componentController('vnClientSummary', {$element, $scope});
|
||||
controller = $componentController('vnClientSummary', {$element});
|
||||
controller.client = {id: 101};
|
||||
}));
|
||||
|
||||
|
@ -48,5 +48,82 @@ describe('Client', () => {
|
|||
expect(result).toEqual(300);
|
||||
});
|
||||
});
|
||||
|
||||
describe('chipColor()', () => {
|
||||
it('should return warning when the date is the present', () => {
|
||||
let today = new Date();
|
||||
let result = controller.chipColor(today);
|
||||
|
||||
expect(result).toEqual('warning');
|
||||
});
|
||||
|
||||
it('should return success when the date is in the future', () => {
|
||||
let futureDate = new Date();
|
||||
futureDate = futureDate.setDate(futureDate.getDate() + 10);
|
||||
let result = controller.chipColor(futureDate);
|
||||
|
||||
expect(result).toEqual('success');
|
||||
});
|
||||
|
||||
it('should return undefined when the date is in the past', () => {
|
||||
let pastDate = new Date();
|
||||
pastDate = pastDate.setDate(pastDate.getDate() - 10);
|
||||
let result = controller.chipColor(pastDate);
|
||||
|
||||
expect(result).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('stateColor()', () => {
|
||||
it('should return "success" when the alertLevelCode property is "OK"', () => {
|
||||
const result = controller.stateColor({alertLevelCode: 'OK'});
|
||||
|
||||
expect(result).toEqual('success');
|
||||
});
|
||||
|
||||
it('should return "notice" when the alertLevelCode property is "FREE"', () => {
|
||||
const result = controller.stateColor({alertLevelCode: 'FREE'});
|
||||
|
||||
expect(result).toEqual('notice');
|
||||
});
|
||||
|
||||
it('should return "warning" when the alertLevel property is "1', () => {
|
||||
const result = controller.stateColor({alertLevel: 1});
|
||||
|
||||
expect(result).toEqual('warning');
|
||||
});
|
||||
|
||||
it('should return "alert" when the alertLevel property is "0"', () => {
|
||||
const result = controller.stateColor({alertLevel: 0});
|
||||
|
||||
expect(result).toEqual('alert');
|
||||
});
|
||||
});
|
||||
|
||||
describe('totalPriceColor()', () => {
|
||||
it('should return "warning" when the ticket amount is less than 50€', () => {
|
||||
const result = controller.totalPriceColor({totalWithVat: '8.50'});
|
||||
|
||||
expect(result).toEqual('warning');
|
||||
});
|
||||
});
|
||||
|
||||
describe('preview()', () => {
|
||||
it('should show the dialog summary', () => {
|
||||
controller.$.summary = {show: () => {}};
|
||||
jest.spyOn(controller.$.summary, 'show');
|
||||
|
||||
const ticket = {id: 1, clientFk: 101};
|
||||
|
||||
const event = new MouseEvent('click', {
|
||||
view: $window,
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
controller.preview(event, ticket);
|
||||
|
||||
expect(controller.$.summary.show).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue