Viewing File: /usr/local/cpanel/base/frontend/jupiter/site-monitor/directives/whatsShowingDirective.spec.js
/*
# site-monitor/directives/whatsShowingDirective.spec.js Copyright 2021 cPanel, L.L.C.
# All rights reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
*/
/* global define: false, describe: false, it: false, module: false, inject: false, beforeEach: false, expect: false */
define(["angular",
"jquery",
"cjt/core",
"ngResource",
"ngMocks",
"site-monitor/directives/whatsShowingDirective"], function(angular) {
"use strict";
describe("<whats-showing>", function() {
var $scope, $rootScope, $compile;
beforeEach(function() {
module("directives/whatsShowingDirective.phtml");
module("cpanel.siteMonitor.whatsShowingDirective");
});
beforeEach(inject(function(_$rootScope_, _$compile_) {
$compile = _$compile_;
$rootScope = _$rootScope_;
}));
/**
* Compile the directives template.
*
* @param {object} scope - initial value for the directives scope
* @returns {Directive}
*/
function compileDirective(scope) {
$scope = $rootScope.$new();
angular.extend($scope, {}, scope);
var $directive = $compile("<whats-showing \
id=\"{{id}}\" \
start=\"start\" \
limit=\"limit\" \
total=\"total\"> \
</whats-showing>")($scope);
$scope.$digest();
return $directive;
}
it("does it create id's for elements", function() {
var scope = {
id: "whats-showing-id",
start: 1,
limit: 2,
total: 10
};
var $directive = compileDirective(scope);
expect($directive.attr("id")).toBe(scope.id);
});
it("outputs expected string", function() {
var scope = {
id: "whats-showing-id",
start: 1,
limit: 2,
total: 10
};
var $directive = compileDirective(scope);
var text = $directive.text();
expect(text).toMatch($scope.start + " through " + $scope.limit);
expect(text).toMatch("out of " + $scope.total);
$scope.total = 500;
$scope.$digest();
var text = $directive.text();
expect(text).toMatch($scope.start + " through " + $scope.limit);
expect(text).toMatch("out of " + $scope.total);
});
});
});
Back to Directory
File Manager