//--- CODE --------------------------
(function (angular) {
// Create module
angular.module('mainMod', [])
.directive('toolTip', [function () {
return {
restrict: 'A',
scope: {
theTooltip: '@toolTip'
},
link: function (scope, element, attrs) {
element.tooltip({content : scope.theTooltip,
tooltipClass: "hover"});
}
}
}]);
})(angular);
// ---SPECS-------------------------
describe('Unit testing tooltip', function () {
var $compile;
var $rootScope;
var $scope;
var element;
var isolateScope;
// Load the myApp module, which contains the directive
beforeEach(module('mainMod'));
beforeEach(inject(function (_$compile_, _$rootScope_) {
$compile = _$compile_;
$rootScope = _$rootScope_;
//create a new scope here
$scope = $rootScope.$new();
//create a directive before each test case
element = angular.element("<span class='icon' tool-tip='This is the tooltip data'></span>");
//use the current scope has just been created above for the directive
$compile(element)($scope);
$scope.$digest();
isolateScope = element.isolateScope();
}));
it('should have data in tooltip', function () {
expect(isolateScope.theTooltip).toBe('This is the tooltip data');
});
});
// --- Runner -------------------------
(function () {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.specFilter = function (spec) {
return htmlReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function () {
if (currentWindowOnload) {
currentWindowOnload();
}
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.