Tarea #480 /icon-menu/icon-menu.js Front unit test
This commit is contained in:
parent
367604654c
commit
e03241fcc6
|
@ -0,0 +1,53 @@
|
|||
import './icon-menu.js';
|
||||
|
||||
describe('Component vnIconMenu', () => {
|
||||
let $componentController;
|
||||
let controller;
|
||||
let $element;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('ticket');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject(_$componentController_ => {
|
||||
$componentController = _$componentController_;
|
||||
$element = angular.element(`<div class="shown"></div>`);
|
||||
controller = $componentController('vnIconMenu', {$element: $element, $transclude: null});
|
||||
}));
|
||||
|
||||
describe('getFields()', () => {
|
||||
it(`should return an array with the fields selectables`, () => {
|
||||
let fields = controller.getFields();
|
||||
|
||||
expect(fields).toEqual(['id', 'name']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('onClick(event)', () => {
|
||||
it(`should call preventDefault, onOpen and showDropdown`, () => {
|
||||
let event = {preventDefault: () => {}};
|
||||
controller.onOpen = () => {};
|
||||
spyOn(event, 'preventDefault');
|
||||
spyOn(controller, 'showDropDown');
|
||||
spyOn(controller, 'onOpen');
|
||||
|
||||
controller.onClick(event);
|
||||
|
||||
expect(event.preventDefault).toHaveBeenCalledWith();
|
||||
expect(controller.showDropDown).toHaveBeenCalledWith();
|
||||
expect(controller.onOpen).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('onDropDownSelect(value)', () => {
|
||||
it(`should set field to a given value and call onChange`, () => {
|
||||
controller.onChange = () => {};
|
||||
spyOn(controller, 'onChange');
|
||||
|
||||
controller.onDropDownSelect('mariano');
|
||||
|
||||
expect(controller.field).toBe('mariano');
|
||||
expect(controller.onChange).toHaveBeenCalledWith({value: 'mariano'});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue