mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[config] added tests for 6df7b2d
This commit is contained in:
parent
e3265063a4
commit
4b9e2c48d8
1 changed files with 59 additions and 0 deletions
59
src/ui/public/directives/__tests__/config.js
Normal file
59
src/ui/public/directives/__tests__/config.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
var ngMock = require('ngMock');
|
||||
var $ = require('jquery');
|
||||
var assign = require('lodash').assign;
|
||||
var expect = require('expect.js');
|
||||
|
||||
describe('Config Directive', function () {
|
||||
|
||||
var build = function () {};
|
||||
|
||||
beforeEach(ngMock.module('kibana', function ($compileProvider) {
|
||||
var renderCount = 0;
|
||||
$compileProvider.directive('renderCounter', function () {
|
||||
return {
|
||||
link: function ($scope, $el) {
|
||||
$el.html(++renderCount);
|
||||
}
|
||||
};
|
||||
});
|
||||
}));
|
||||
|
||||
beforeEach(ngMock.inject(function ($compile, $rootScope) {
|
||||
|
||||
build = function (attrs, scopeVars) {
|
||||
var $el = $('<config>').attr(attrs);
|
||||
var $scope = $rootScope.$new();
|
||||
assign($scope, scopeVars || {});
|
||||
$compile($el)($scope);
|
||||
$scope.$digest();
|
||||
return $el;
|
||||
};
|
||||
|
||||
}));
|
||||
|
||||
it('renders it\'s config template', function () {
|
||||
var $config = build({ 'config-template': '"<uniqel></uniqel>"' });
|
||||
expect($config.find('uniqel').size()).to.be(1);
|
||||
});
|
||||
|
||||
it('exposes an object a config object using it\'s name', function () {
|
||||
var $config = build(
|
||||
{
|
||||
'config-template': '"<uniqel>{{ controller.name }}</uniqel>"',
|
||||
'config-object': 'controller',
|
||||
},
|
||||
{
|
||||
controller: {
|
||||
name: 'foobar'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
expect($config.find('uniqel').text()).to.be('foobar');
|
||||
});
|
||||
|
||||
it('only renders the config-template once', function () {
|
||||
var $config = build({ 'config-template': '"<div render-counter></div>"' });
|
||||
expect($config.find('[render-counter]').text()).to.be('1');
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue