Skip to content
This repository has been archived by the owner on Jun 21, 2018. It is now read-only.

Commit

Permalink
Add mmaintenance directive test
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlexx committed May 7, 2016
1 parent 8df17eb commit f0e825b
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions static/tests/directives/maintenance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,27 @@ describe("directive: moira-maintenance", () => {
$httpBackend.verifyNoOutstandingRequest();
});

describe("maintenance compilation", () => {
describe("maintenance scope", () => {
var now = moment.utc().unix();
beforeEach(() => {
$httpBackend.expectPUT("/trigger/triggerid/maintenance").respond({});
scope.set_metric_maintenance(15, scope.$emit('click'));
$httpBackend.flush();
describe("set maintenance to 15 min", () => {
beforeEach(() => {
$httpBackend.expectPUT("/trigger/triggerid/maintenance").respond({});
scope.set_metric_maintenance(15, scope.$emit('click'));
$httpBackend.flush();
});
it("check maintenance must set to non-zero", () => {
expect(scope.check.json.maintenance >= now + 15 * 60 && scope.check.json.maintenance < now + 16 * 60).toBeTruthy();
expect(scope.remaining).toEqual("15 minutes");
});
});
it("check maintenance must set to non-zero", () => {
expect(scope.check.json.maintenance >= now + 15 * 60 && scope.check.json.maintenance < now + 16 * 60).toBeTruthy();
describe("undefined maintenance", () => {
beforeEach(() => {
$httpBackend.flush();
});
it("means no remaining time", () => {
expect(scope.check.json.maintenance).toBeUndefined();
expect(scope.remaining).toEqual("off");
});
});
});

Expand Down

0 comments on commit f0e825b

Please sign in to comment.