2017-10-11 10:57:13 +00:00
|
|
|
import './drop-down.js';
|
2018-03-09 13:15:30 +00:00
|
|
|
import template from './drop-down.html';
|
2017-10-11 10:57:13 +00:00
|
|
|
|
|
|
|
describe('Component vnDropDown', () => {
|
|
|
|
let $componentController;
|
|
|
|
let $timeout;
|
|
|
|
let $element;
|
2018-03-09 13:15:30 +00:00
|
|
|
let $scope;
|
|
|
|
let $httpBackend;
|
2018-03-12 11:31:50 +00:00
|
|
|
let $transitions;
|
2018-03-09 13:15:30 +00:00
|
|
|
let $q;
|
2017-10-11 10:57:13 +00:00
|
|
|
let $filter;
|
2017-10-17 12:24:40 +00:00
|
|
|
let controller;
|
2017-10-11 10:57:13 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
angular.mock.module('client');
|
|
|
|
});
|
|
|
|
|
2018-03-12 11:31:50 +00:00
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$timeout_, _$httpBackend_, _$q_, _$filter_, _$transitions_) => {
|
2017-10-11 10:57:13 +00:00
|
|
|
$componentController = _$componentController_;
|
2018-03-09 13:15:30 +00:00
|
|
|
$element = angular.element(`<div>${template}</div>`);
|
2017-10-11 10:57:13 +00:00
|
|
|
$timeout = _$timeout_;
|
2018-03-12 11:31:50 +00:00
|
|
|
$transitions = _$transitions_;
|
2018-03-09 13:15:30 +00:00
|
|
|
$q = _$q_;
|
2017-10-11 10:57:13 +00:00
|
|
|
$filter = _$filter_;
|
2018-03-09 13:15:30 +00:00
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
|
|
|
|
2018-03-12 11:31:50 +00:00
|
|
|
let popoverTemplate = require('../popover/popover.html');
|
|
|
|
let $popover = angular.element(`<div>${popoverTemplate}</div>`);
|
|
|
|
$scope.popover = $componentController('vnPopover', {$element: $popover, $scope, $timeout, $transitions});
|
2018-03-13 11:07:28 +00:00
|
|
|
$scope.popover.$postLink();
|
|
|
|
|
2018-05-31 09:52:39 +00:00
|
|
|
$scope.model = $componentController('vnRestModel', {$httpBackend, $q, $filter});
|
2018-03-09 13:15:30 +00:00
|
|
|
controller = $componentController('vnDropDown', {$element, $scope, $transclude: null, $timeout, $httpBackend, $translate: null});
|
2018-03-12 11:31:50 +00:00
|
|
|
controller.$postLink();
|
2017-11-22 12:10:33 +00:00
|
|
|
controller.parent = angular.element('<vn-parent></vn-parent>')[0];
|
2017-10-11 10:57:13 +00:00
|
|
|
}));
|
|
|
|
|
2018-03-09 13:15:30 +00:00
|
|
|
describe('show() method', () => {
|
2017-10-11 10:57:13 +00:00
|
|
|
it(`should define controllers _show using the value received as argument`, () => {
|
2018-03-09 13:15:30 +00:00
|
|
|
controller.show();
|
2017-10-11 10:57:13 +00:00
|
|
|
|
2018-03-09 13:15:30 +00:00
|
|
|
expect(controller.shown).toEqual(true);
|
2017-10-11 10:57:13 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-03-09 13:15:30 +00:00
|
|
|
describe('hide() method', () => {
|
|
|
|
it(`should define controllers _show using the value received as argument`, () => {
|
|
|
|
controller.hide();
|
2017-10-13 08:23:28 +00:00
|
|
|
|
2018-03-09 13:15:30 +00:00
|
|
|
expect(controller.shown).toEqual(false);
|
2017-10-13 08:23:28 +00:00
|
|
|
});
|
|
|
|
});
|
2017-10-11 10:57:13 +00:00
|
|
|
});
|