fix: build & tests

This commit is contained in:
Torkel Ödegaard 2017-11-17 16:18:30 +01:00
parent 7b17d134fc
commit 8160e68f93
3 changed files with 68 additions and 73 deletions

View File

@ -1,6 +1,6 @@
module.exports = { module.exports = {
verbose: true, verbose: false,
"globals": { "globals": {
"ts-jest": { "ts-jest": {
"tsConfigFile": "tsconfig.json" "tsConfigFile": "tsconfig.json"

View File

@ -51,7 +51,6 @@
</a> </a>
</div> </div>
</div> </div>
</div>
<div class="search-results-container" ng-if="!ctrl.tagsMode"> <div class="search-results-container" ng-if="!ctrl.tagsMode">
<h6 ng-hide="ctrl.results.length">No dashboards matching your query were found.</h6> <h6 ng-hide="ctrl.results.length">No dashboards matching your query were found.</h6>
@ -75,5 +74,6 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>

View File

@ -1,67 +1,62 @@
import {SaveDashboardAsModalCtrl} from '../save_as_modal'; import { SaveDashboardAsModalCtrl } from '../save_as_modal';
import {describe, it, expect} from 'test/lib/common'; import { describe, it, expect } from 'test/lib/common';
describe('saving dashboard as', () => { describe('saving dashboard as', () => {
function scenario(name, panel, verify) { function scenario(name, panel, verify) {
describe(name, () => { describe(name, () => {
var json = { var json = {
title: "name", title: 'name',
rows: [ { panels: [ panels: [panel],
panel
]}]
}; };
var mockDashboardSrv = { var mockDashboardSrv = {
getCurrent: function() { getCurrent: function() {
return { return {
id: 5, id: 5,
meta: {},
getSaveModelClone: function() { getSaveModelClone: function() {
return json; return json;
} },
}; };
} },
}; };
var ctrl = new SaveDashboardAsModalCtrl(mockDashboardSrv); var ctrl = new SaveDashboardAsModalCtrl(mockDashboardSrv);
var ctx: any = { var ctx: any = {
clone: ctrl.clone, clone: ctrl.clone,
ctrl: ctrl, ctrl: ctrl,
panel: {} panel: panel
}; };
for (let row of ctrl.clone.rows) {
for (let panel of row.panels) { it('verify', () => {
ctx.panel = panel;
}
}
it("verify", () => {
verify(ctx); verify(ctx);
}); });
}); });
} }
scenario("default values", {}, (ctx) => { scenario('default values', {}, ctx => {
var clone = ctx.clone; var clone = ctx.clone;
expect(clone.id).toBe(null); expect(clone.id).toBe(null);
expect(clone.title).toBe("name Copy"); expect(clone.title).toBe('name Copy');
expect(clone.editable).toBe(true); expect(clone.editable).toBe(true);
expect(clone.hideControls).toBe(false); expect(clone.hideControls).toBe(false);
}); });
var graphPanel = { id: 1, type: "graph", alert: { rule: 1}, thresholds: { value: 3000} }; var graphPanel = { id: 1, type: 'graph', alert: { rule: 1 }, thresholds: { value: 3000 } };
scenario("should remove alert from graph panel", graphPanel , (ctx) => { scenario('should remove alert from graph panel', graphPanel, ctx => {
expect(ctx.panel.alert).toBe(undefined); expect(ctx.panel.alert).toBe(undefined);
}); });
scenario("should remove threshold from graph panel", graphPanel, (ctx) => { scenario('should remove threshold from graph panel', graphPanel, ctx => {
expect(ctx.panel.thresholds).toBe(undefined); expect(ctx.panel.thresholds).toBe(undefined);
}); });
scenario("singlestat should keep threshold", { id: 1, type: "singlestat", thresholds: { value: 3000} }, (ctx) => { scenario('singlestat should keep threshold', { id: 1, type: 'singlestat', thresholds: { value: 3000 } }, ctx => {
expect(ctx.panel.thresholds).not.toBe(undefined); expect(ctx.panel.thresholds).not.toBe(undefined);
}); });
scenario("table should keep threshold", { id: 1, type: "table", thresholds: { value: 3000} }, (ctx) => { scenario('table should keep threshold', { id: 1, type: 'table', thresholds: { value: 3000 } }, ctx => {
expect(ctx.panel.thresholds).not.toBe(undefined); expect(ctx.panel.thresholds).not.toBe(undefined);
}); });
}); });