/usr/share/maas/web/static/js/angular/directives/tests/test_script_status.js is in maas-region-api 2.4.0~beta2-6865-gec43e47e6-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | /* Copyright 2017 Canonical Ltd. This software is licensed under the
* GNU Affero General Public License version 3 (see the file LICENSE).
*
* Unit tests for script status icon select directive.
*/
describe("maasScriptStatus", function() {
// Load the MAAS module.
beforeEach(module("MAAS"));
// Create a new scope before each test.
var $scope;
beforeEach(inject(function($rootScope) {
$scope = $rootScope.$new();
$scope.scriptStatus = null;
$scope.icon = null;
}));
// Return the compiled directive with the maasScriptStatus from the scope.
function compileDirective(scriptStatus) {
var directive;
var html = '<div><span data-maas-script-status="script-status"' +
'data-script_status="' + scriptStatus + '"></span></div>';
// Compile the directive.
inject(function($compile) {
directive = $compile(html)($scope);
});
// Perform the digest cycle to finish the compile.
$scope.$digest();
return directive.find("span");
}
it("SCRIPT_STATUS.PENDING", function() {
var directive = compileDirective("0");
var select = directive.find("span");
expect(select.attr("class")).toBe("p-icon--pending");
});
it("SCRIPT_STATUS.RUNNING", function() {
var directive = compileDirective("1");
var select = directive.find("span");
expect(select.attr("class")).toBe("p-icon--running");
});
it("SCRIPT_STATUS.INSTALLING", function() {
var directive = compileDirective("7");
var select = directive.find("span");
expect(select.attr("class")).toBe("p-icon--running");
});
it("SCRIPT_STATUS.PASSED", function() {
var directive = compileDirective("2");
var select = directive.find("span");
expect(select.attr("class")).toBe("p-icon--pass");
});
it("SCRIPT_STATUS.FAILED", function() {
var directive = compileDirective("3");
var select = directive.find("span");
expect(select.attr("class")).toBe("p-icon--power-error");
});
it("SCRIPT_STATUS.ABORTED", function() {
var directive = compileDirective("5");
var select = directive.find("span");
expect(select.attr("class")).toBe("p-icon--power-error");
});
it("SCRIPT_STATUS.DEGRADED", function() {
var directive = compileDirective("6");
var select = directive.find("span");
expect(select.attr("class")).toBe("p-icon--power-error");
});
it("SCRIPT_STATUS.FAILED_INSTALLING", function() {
var directive = compileDirective("8");
var select = directive.find("span");
expect(select.attr("class")).toBe("p-icon--power-error");
});
it("SCRIPT_STATUS.TIMEDOUT", function() {
var directive = compileDirective("4");
var select = directive.find("span");
expect(select.attr("class")).toBe("p-icon--timed-out");
});
it("SCRIPT_STATUS.SKIPPED", function() {
var directive = compileDirective("9");
var select = directive.find("span");
expect(select.attr("class")).toBe("p-icon--warning");
});
it("NONE", function() {
var directive = compileDirective("-1");
var select = directive.find("span");
expect(select.attr("context")).toBe(undefined);
});
it("UNKNOWN", function() {
var directive = compileDirective("99");
var select = directive.find("span");
expect(select.attr("class")).toBe("p-icon--help");
});
});
|