salix/client/core/src/components/drop-down/drop-down.spec.js

57 lines
1.9 KiB
JavaScript
Raw Normal View History

import './drop-down.js';
2018-03-09 13:15:30 +00:00
import template from './drop-down.html';
describe('Component vnDropDown', () => {
let $componentController;
let $timeout;
let $element;
2018-03-09 13:15:30 +00:00
let $scope;
let $httpBackend;
let $transitions;
2018-03-09 13:15:30 +00:00
let $q;
let $filter;
let controller;
beforeEach(() => {
angular.mock.module('client');
});
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$timeout_, _$httpBackend_, _$q_, _$filter_, _$transitions_) => {
$componentController = _$componentController_;
2018-03-09 13:15:30 +00:00
$element = angular.element(`<div>${template}</div>`);
$timeout = _$timeout_;
$transitions = _$transitions_;
2018-03-09 13:15:30 +00:00
$q = _$q_;
$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({});
let popoverTemplate = require('../popover/popover.html');
let $popover = angular.element(`<div>${popoverTemplate}</div>`);
$scope.popover = $componentController('vnPopover', {$element: $popover, $scope, $timeout, $transitions});
$scope.popover.$postLink();
$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});
controller.$postLink();
2017-11-22 12:10:33 +00:00
controller.parent = angular.element('<vn-parent></vn-parent>')[0];
}));
2018-03-09 13:15:30 +00:00
describe('show() method', () => {
it(`should define controllers _show using the value received as argument`, () => {
2018-03-09 13:15:30 +00:00
controller.show();
2018-03-09 13:15:30 +00:00
expect(controller.shown).toEqual(true);
});
});
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
});
});
});