first commit
This commit is contained in:
359
spec/javascripts/array_visualization_spec.js
Normal file
359
spec/javascripts/array_visualization_spec.js
Normal file
@@ -0,0 +1,359 @@
|
||||
import ArrayVisualization from '../../helix/javascript/array_summary/array_visualization';
|
||||
import $ from 'jquery';
|
||||
import 'jasmine-jquery';
|
||||
import * as PanelExports from '../../helix/javascript/array_summary/panel';
|
||||
|
||||
describe("The array visualization", function () {
|
||||
let Panel;
|
||||
let isDualTilt = false;
|
||||
let subject;
|
||||
let containerSpy;
|
||||
let subarrayDisplaySpy;
|
||||
|
||||
beforeEach(function () {
|
||||
const panel = jasmine.createSpyObj("shape",
|
||||
["dispatchEvent", "zoom", "setOverlay", "on", "select", "deselect", "redrawOverlays"]);
|
||||
spyOn(PanelExports, 'Panel').and.returnValue(panel);
|
||||
Panel = PanelExports.Panel;
|
||||
subarrayDisplaySpy = jasmine.createSpyObj("SubarrayDisplay", ["didModifyPanels"]);
|
||||
|
||||
let panelData = [
|
||||
{'x': 1, 'y': 1, 'width': 1, 'height': 1, 'data': {'ballast': 3, 'seismic_anchors': 3}},
|
||||
{'x': 1, 'y': 2, 'width': 1, 'height': 1, 'data': {'ballast': 4, 'seismic_anchors': 2}},
|
||||
{'x': 1, 'y': 1, 'width': 1, 'height': 1, 'data': {'ballast': 7, 'seismic_anchors': 0}},
|
||||
{'x': 2, 'y': 1, 'width': 1, 'height': 1, 'data': {'ballast': 1, 'seismic_anchors': 1}},
|
||||
{'x': 2, 'y': 2, 'width': 1, 'height': 1, 'data': {'ballast': 6, 'seismic_anchors': 0}}
|
||||
];
|
||||
|
||||
let buildings = [[ {'x': -60, 'y': 60, 'rotation': 0.0},
|
||||
{'x': 60, 'y': 60, 'rotation': 0.0},
|
||||
{'x': 60, 'y': -60, 'rotation': 0.0},
|
||||
{'x': -60, 'y': -60, 'rotation': 0.0}]];
|
||||
|
||||
subject = new ArrayVisualization(panelData, isDualTilt, subarrayDisplaySpy, buildings);
|
||||
});
|
||||
|
||||
describe('#init', function () {
|
||||
beforeEach(function () {
|
||||
containerSpy = jasmine.createSpyObj("container", ["addChild", "removeChild", "dispatchEvent"]);
|
||||
spyOn(createjs, "Container").and.returnValue(containerSpy);
|
||||
subject.init();
|
||||
});
|
||||
|
||||
it("creates a panel for each panel in the visualization", function () {
|
||||
expect(Panel.calls.count()).toEqual(5);
|
||||
expect(Panel.calls.argsFor(0)).toEqual([{
|
||||
'x': 1,
|
||||
'y': 1,
|
||||
'width': 1,
|
||||
'height': 1,
|
||||
'data': {'ballast': 3, 'seismic_anchors': 3}
|
||||
}, isDualTilt, 10, true]);
|
||||
expect(Panel.calls.argsFor(1)).toEqual([{
|
||||
'x': 1,
|
||||
'y': 2,
|
||||
'width': 1,
|
||||
'height': 1,
|
||||
'data': {'ballast': 4, 'seismic_anchors': 2}
|
||||
}, isDualTilt, 10, true]);
|
||||
expect(Panel.calls.argsFor(2)).toEqual([{
|
||||
'x': 1,
|
||||
'y': 1,
|
||||
'width': 1,
|
||||
'height': 1,
|
||||
'data': {'ballast': 7, 'seismic_anchors': 0}
|
||||
}, isDualTilt, 10, true]);
|
||||
expect(Panel.calls.argsFor(3)).toEqual([{
|
||||
'x': 2,
|
||||
'y': 1,
|
||||
'width': 1,
|
||||
'height': 1,
|
||||
'data': {'ballast': 1, 'seismic_anchors': 1}
|
||||
}, isDualTilt, 10, true]);
|
||||
expect(Panel.calls.argsFor(4)).toEqual([{
|
||||
'x': 2,
|
||||
'y': 2,
|
||||
'width': 1,
|
||||
'height': 1,
|
||||
'data': {'ballast': 6, 'seismic_anchors': 0}
|
||||
}, isDualTilt, 10, true]);
|
||||
});
|
||||
|
||||
it("adds the panels and buildings to the container", function () {
|
||||
expect(containerSpy.addChild.calls.count()).toEqual(6);
|
||||
});
|
||||
|
||||
it("adds the container to the stage", function () {
|
||||
expect(subject.stage.children).toContain(containerSpy);
|
||||
});
|
||||
|
||||
describe("selecting a panel", function () {
|
||||
let panel;
|
||||
beforeEach(function () {
|
||||
panel = subject.panels[0];
|
||||
subject.selectPanel(0);
|
||||
});
|
||||
|
||||
it("marks the panel as selected", function () {
|
||||
expect(panel.select).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("deselects this panel when another panel is selected", function () {
|
||||
subject.selectPanel(1);
|
||||
expect(panel.deselect).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("deselects the panel when it is selected again", function () {
|
||||
panel.select.calls.reset();
|
||||
panel.deselect.calls.reset();
|
||||
subject.selectPanel(0);
|
||||
expect(panel.deselect).toHaveBeenCalled();
|
||||
expect(panel.select).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("panning", function () {
|
||||
describe("dragging on the canvas", function () {
|
||||
beforeEach(function () {
|
||||
let event = new createjs.Event("pressmove");
|
||||
event.stageX = 5;
|
||||
event.stageY = 3;
|
||||
subject.stage.dispatchEvent(event);
|
||||
});
|
||||
|
||||
it("does nothing on the first invocation", function () {
|
||||
expect(containerSpy.x).toEqual(0);
|
||||
expect(containerSpy.y).toEqual(0);
|
||||
});
|
||||
|
||||
describe("the subsequent pressmove after the first", function () {
|
||||
beforeEach(function () {
|
||||
let event = new createjs.Event("pressmove");
|
||||
event.stageX = 10;
|
||||
event.stageY = 5;
|
||||
subject.stage.dispatchEvent(event);
|
||||
});
|
||||
|
||||
it("moves the container based on the delta of the this and the previous pressmove", function () {
|
||||
expect(containerSpy.x).toEqual(5);
|
||||
expect(containerSpy.y).toEqual(2);
|
||||
});
|
||||
|
||||
describe("ending the pressmove and starting again", function () {
|
||||
beforeEach(function () {
|
||||
subject.stage.dispatchEvent("pressup");
|
||||
|
||||
let event = new createjs.Event("pressmove");
|
||||
event.stageX = 9;
|
||||
event.stageY = 3;
|
||||
subject.stage.dispatchEvent(event);
|
||||
});
|
||||
|
||||
it("does not move the container again", function () {
|
||||
expect(containerSpy.x).toEqual(5);
|
||||
expect(containerSpy.y).toEqual(2);
|
||||
});
|
||||
|
||||
it("moves the container based on the delta of this on subsequent pressmove events", function () {
|
||||
let event = new createjs.Event("pressmove");
|
||||
event.stageX = 15;
|
||||
event.stageY = 33;
|
||||
subject.stage.dispatchEvent(event);
|
||||
expect(containerSpy.x).toEqual(11);
|
||||
expect(containerSpy.y).toEqual(32);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("zooming", function () {
|
||||
it("changes the scale of the container", function () {
|
||||
subject.setZoom(5);
|
||||
|
||||
expect(subject.container.scaleX).toEqual(5);
|
||||
expect(subject.container.scaleY).toEqual(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe("changing the overlays", function () {
|
||||
it("changes the selected overlays on the Panel object", function () {
|
||||
subject.setOverlay("ooga");
|
||||
|
||||
subject.panels.forEach(function (panel) {
|
||||
expect(panel.setOverlay).toHaveBeenCalledWith("ooga");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("adding seismic anchors", function () {
|
||||
describe("when no panel is selected", function () {
|
||||
beforeEach(function () {
|
||||
subject.addSeismicAnchor();
|
||||
});
|
||||
|
||||
it("does nothing", function () {
|
||||
expect(subject.panelData[0].data.seismic_anchors).toEqual(3);
|
||||
expect(subject.panelData[1].data.seismic_anchors).toEqual(2);
|
||||
expect(subject.panelData[2].data.seismic_anchors).toEqual(0);
|
||||
expect(subject.panelData[3].data.seismic_anchors).toEqual(1);
|
||||
expect(subject.panelData[4].data.seismic_anchors).toEqual(0);
|
||||
|
||||
for (let i = 0; i < subject.panels.length; i++) {
|
||||
expect(subject.panels[i].redrawOverlays).not.toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not call the seismic monitor spy", function () {
|
||||
expect(subarrayDisplaySpy.didModifyPanels).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a panel is selected", function () {
|
||||
beforeEach(function () {
|
||||
subject.selectPanel(0);
|
||||
subject.addSeismicAnchor();
|
||||
});
|
||||
|
||||
it("increases the number of seismic anchors for that panel by one", function () {
|
||||
expect(subject.panelData[0].data.seismic_anchors).toEqual(4);
|
||||
});
|
||||
|
||||
it("refreshes the text on the panel object", function () {
|
||||
expect(subject.panels[0].redrawOverlays).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls the seismic monitor spy", function () {
|
||||
expect(subarrayDisplaySpy.didModifyPanels).toHaveBeenCalledWith(subject.panelData);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("removing seismic anchors", function () {
|
||||
describe("when no panel is selected", function () {
|
||||
beforeEach(function () {
|
||||
subject.removeSeismicAnchor();
|
||||
});
|
||||
|
||||
it("does nothing", function () {
|
||||
expect(subject.panelData[0].data.seismic_anchors).toEqual(3);
|
||||
expect(subject.panelData[1].data.seismic_anchors).toEqual(2);
|
||||
expect(subject.panelData[2].data.seismic_anchors).toEqual(0);
|
||||
expect(subject.panelData[3].data.seismic_anchors).toEqual(1);
|
||||
expect(subject.panelData[4].data.seismic_anchors).toEqual(0);
|
||||
|
||||
for (let i = 0; i < subject.panels.length; i++) {
|
||||
expect(subject.panels[i].redrawOverlays).not.toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not call the seismic monitor spy", function () {
|
||||
expect(subarrayDisplaySpy.didModifyPanels).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a panel with no seismic anchors is selected", function () {
|
||||
beforeEach(function () {
|
||||
subject.selectPanel(2);
|
||||
subject.removeSeismicAnchor();
|
||||
});
|
||||
|
||||
it("does nothing", function () {
|
||||
expect(subject.panelData[0].data.seismic_anchors).toEqual(3);
|
||||
expect(subject.panelData[1].data.seismic_anchors).toEqual(2);
|
||||
expect(subject.panelData[2].data.seismic_anchors).toEqual(0);
|
||||
expect(subject.panelData[3].data.seismic_anchors).toEqual(1);
|
||||
expect(subject.panelData[4].data.seismic_anchors).toEqual(0);
|
||||
|
||||
for (let i = 0; i < subject.panels.length; i++) {
|
||||
expect(subject.panels[i].redrawOverlays).not.toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not call the seismic monitor spy", function () {
|
||||
expect(subarrayDisplaySpy.didModifyPanels).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a panel with seismic anchors is selected", function () {
|
||||
beforeEach(function () {
|
||||
subject.selectPanel(1);
|
||||
subject.removeSeismicAnchor();
|
||||
});
|
||||
|
||||
it("increases the number of seismic anchors for that panel by one", function () {
|
||||
expect(subject.panelData[1].data.seismic_anchors).toEqual(1);
|
||||
});
|
||||
|
||||
it("refreshes the text on the panel object", function () {
|
||||
expect(subject.panels[1].redrawOverlays).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls the seismic monitor spy", function () {
|
||||
expect(subarrayDisplaySpy.didModifyPanels).toHaveBeenCalledWith(subject.panelData);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("refreshing the panels", function () {
|
||||
let panelData = [
|
||||
{'x': 1, 'y': 1, 'width': 1, 'height': 1, 'data': {'ballast': 3, 'seismic_anchors': 3}},
|
||||
{'x': 1, 'y': 2, 'width': 1, 'height': 1, 'data': {'ballast': 4, 'seismic_anchors': 2}},
|
||||
{'x': 1, 'y': 1, 'width': 1, 'height': 1, 'data': {'ballast': 7, 'seismic_anchors': 0}},
|
||||
{'x': 2, 'y': 1, 'width': 1, 'height': 1, 'data': {'ballast': 1, 'seismic_anchors': 1}},
|
||||
{'x': 2, 'y': 2, 'width': 1, 'height': 1, 'data': {'ballast': 6, 'seismic_anchors': 0}}
|
||||
];
|
||||
beforeEach(function () {
|
||||
|
||||
subject.refreshPanels(panelData);
|
||||
});
|
||||
|
||||
it("removes the existing panels from the container", function () {
|
||||
expect(containerSpy.removeChild.calls.count()).toEqual(5);
|
||||
});
|
||||
|
||||
it("tells the subarray_display that we modified the panels", function () {
|
||||
expect(subarrayDisplaySpy.didModifyPanels).toHaveBeenCalledWith(panelData);
|
||||
});
|
||||
|
||||
it("creates new panels and adds them to the container", function () {
|
||||
expect(Panel.calls.count()).toEqual(10);
|
||||
expect(Panel.calls.argsFor(5)).toEqual([{
|
||||
'x': 1,
|
||||
'y': 1,
|
||||
'width': 1,
|
||||
'height': 1,
|
||||
'data': {'ballast': 3, 'seismic_anchors': 3}
|
||||
}, isDualTilt, 10, true]);
|
||||
expect(Panel.calls.argsFor(6)).toEqual([{
|
||||
'x': 1,
|
||||
'y': 2,
|
||||
'width': 1,
|
||||
'height': 1,
|
||||
'data': {'ballast': 4, 'seismic_anchors': 2}
|
||||
}, isDualTilt, 10, true]);
|
||||
expect(Panel.calls.argsFor(7)).toEqual([{
|
||||
'x': 1,
|
||||
'y': 1,
|
||||
'width': 1,
|
||||
'height': 1,
|
||||
'data': {'ballast': 7, 'seismic_anchors': 0}
|
||||
}, isDualTilt, 10, true]);
|
||||
expect(Panel.calls.argsFor(8)).toEqual([{
|
||||
'x': 2,
|
||||
'y': 1,
|
||||
'width': 1,
|
||||
'height': 1,
|
||||
'data': {'ballast': 1, 'seismic_anchors': 1}
|
||||
}, isDualTilt, 10, true]);
|
||||
expect(Panel.calls.argsFor(9)).toEqual([{
|
||||
'x': 2,
|
||||
'y': 2,
|
||||
'width': 1,
|
||||
'height': 1,
|
||||
'data': {'ballast': 6, 'seismic_anchors': 0}
|
||||
}, isDualTilt, 10, true]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
35
spec/javascripts/karma.config.js
Normal file
35
spec/javascripts/karma.config.js
Normal file
@@ -0,0 +1,35 @@
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
browsers: ['Chrome'],
|
||||
files: [
|
||||
{
|
||||
pattern: 'test_index.js', watched: false
|
||||
}
|
||||
],
|
||||
frameworks: ['jasmine'],
|
||||
preprocessors: {
|
||||
'test_index.js': ['webpack', 'sourcemap']
|
||||
},
|
||||
webpack: {
|
||||
devtool: 'inline-source-map',
|
||||
module: {
|
||||
loaders: [
|
||||
{
|
||||
test: /\.js/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'babel-loader'
|
||||
},
|
||||
{
|
||||
// That will tell Webpack that EaselJS refers to `window` with `this` and exports `window.createjs`.
|
||||
test: /easeljs\.js$/,
|
||||
loader: 'imports?this=>window!exports?window.createjs'
|
||||
}
|
||||
]
|
||||
},
|
||||
watch: true
|
||||
},
|
||||
webpackServer: {
|
||||
noInfo: true
|
||||
}
|
||||
});
|
||||
};
|
||||
84
spec/javascripts/overlay_control_spec.js
Normal file
84
spec/javascripts/overlay_control_spec.js
Normal file
@@ -0,0 +1,84 @@
|
||||
import OverlayControl from '../../helix/javascript/array_summary/overlay_control';
|
||||
import $ from 'jquery';
|
||||
import 'jasmine-jquery';
|
||||
|
||||
describe('Overlay controls', function () {
|
||||
let htmlContent = '<div id="toggle_buttons"><div id="anchor_overlay" class="overlay_toggle"></div>' +
|
||||
'<div id="all_overlay" class="overlay_toggle"></div></div>';
|
||||
|
||||
let legendContent = '<div id="legend_container"><img class="legend anchors_mode"><img class="legend all_mode"></div>';
|
||||
let visualizationSpy;
|
||||
let subject;
|
||||
|
||||
beforeEach(function () {
|
||||
setFixtures(htmlContent + legendContent);
|
||||
visualizationSpy = jasmine.createSpyObj('arrayVisualization', ['setOverlay']);
|
||||
subject = new OverlayControl(visualizationSpy);
|
||||
subject.init($('#toggle_buttons'), $('#legend_container'));
|
||||
});
|
||||
|
||||
describe("the default state", function () {
|
||||
it("sets the anchors overlay", function () {
|
||||
expect(visualizationSpy.setOverlay).toHaveBeenCalledWith('ANCHOR');
|
||||
expect($('#anchor_overlay')).toHaveClass('overlay_active');
|
||||
});
|
||||
|
||||
it("unselects the other buttons", function () {
|
||||
expect($('#all_overlay')).not.toHaveClass('overlay_active');
|
||||
});
|
||||
|
||||
it("hides the 'all' legend", function () {
|
||||
expect($('img.all_mode')).toBeHidden();
|
||||
});
|
||||
|
||||
it("shows the 'anchors' legend", function () {
|
||||
expect($('img.anchors_mode')).not.toBeHidden();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clicking the all button", function () {
|
||||
beforeEach(function () {
|
||||
$('#all_overlay').click();
|
||||
});
|
||||
it("sets the all overlay", function () {
|
||||
expect(visualizationSpy.setOverlay).toHaveBeenCalledWith('ALL');
|
||||
expect($('#all_overlay')).toHaveClass('overlay_active');
|
||||
});
|
||||
|
||||
it("unselects the other buttons", function () {
|
||||
expect($('#anchor_overlay')).not.toHaveClass('overlay_active');
|
||||
});
|
||||
|
||||
it("shows the 'all' legend", function () {
|
||||
expect($('img.all_mode')).not.toBeHidden();
|
||||
});
|
||||
|
||||
it("hides the 'anchors' legend", function () {
|
||||
expect($('img.anchors_mode')).toBeHidden();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clicking the anchor button", function () {
|
||||
beforeEach(function () {
|
||||
$('#all_overlay').click();
|
||||
visualizationSpy.setOverlay.calls.reset();
|
||||
$('#anchor_overlay').click();
|
||||
});
|
||||
it("sets the anchors overlay", function () {
|
||||
expect(visualizationSpy.setOverlay).toHaveBeenCalledWith('ANCHOR');
|
||||
expect($('#anchor_overlay')).toHaveClass('overlay_active');
|
||||
});
|
||||
|
||||
it("unselects the other buttons", function () {
|
||||
expect($('#all_overlay')).not.toHaveClass('overlay_active');
|
||||
});
|
||||
|
||||
it("hides the 'all' legend", function () {
|
||||
expect($('img.all_mode')).toBeHidden();
|
||||
});
|
||||
|
||||
it("shows the 'anchors' legend", function () {
|
||||
expect($('img.anchors_mode')).not.toBeHidden();
|
||||
});
|
||||
});
|
||||
});
|
||||
188
spec/javascripts/panel_spec.js
Normal file
188
spec/javascripts/panel_spec.js
Normal file
@@ -0,0 +1,188 @@
|
||||
import {Panel} from '../../helix/javascript/array_summary/panel';
|
||||
import Colors from '../../helix/javascript/array_summary/colors';
|
||||
|
||||
describe("A Panel", function () {
|
||||
var panelLocation = {x: 10, y: 20, width: 2, height: 1.5};
|
||||
var subject;
|
||||
var shapeSpy;
|
||||
var panelData;
|
||||
var graphicsSpy;
|
||||
|
||||
beforeEach(function () {
|
||||
var graphicsMethods = ["setStrokeStyle", "beginStroke", "beginFill", "drawRect",
|
||||
"endStroke", "endFill", "closePath", "moveTo", "lineTo"];
|
||||
graphicsSpy = jasmine.createSpyObj("graphics", graphicsMethods);
|
||||
graphicsMethods.forEach(function (method) {
|
||||
graphicsSpy[method].and.returnValue(graphicsSpy);
|
||||
});
|
||||
shapeSpy = {
|
||||
dispatchEvent: jasmine.createSpy("dispatchEvent"),
|
||||
graphics: graphicsSpy
|
||||
};
|
||||
spyOn(createjs, "Shape").and.returnValue(shapeSpy);
|
||||
panelData = {
|
||||
x: 1,
|
||||
y: 2,
|
||||
width: 2,
|
||||
height: 1.5,
|
||||
data: {
|
||||
ballast: 20,
|
||||
wind_anchors: 2,
|
||||
seismic_anchors: 1,
|
||||
wind_zones: 'C',
|
||||
cross_trays: 1,
|
||||
link_trays: 1,
|
||||
panel_id: 1,
|
||||
subarray: 5,
|
||||
panel_type: 4,
|
||||
psf: 3.2379
|
||||
}
|
||||
};
|
||||
subject = new Panel(panelData);
|
||||
});
|
||||
|
||||
it("locates itself at the panel coordinates", function () {
|
||||
expect(subject.x).toEqual(panelLocation.x - subject.width / 2);
|
||||
expect(subject.y).toEqual(panelLocation.y - subject.height / 2);
|
||||
});
|
||||
|
||||
it("has a bounds based on the width and height given", function () {
|
||||
expect(graphicsSpy.drawRect).toHaveBeenCalledWith(0, 0, 20, 15);
|
||||
});
|
||||
|
||||
it("has a single shape child", function () {
|
||||
expect(subject.children).toContain(shapeSpy);
|
||||
});
|
||||
|
||||
describe("background color with anchors", function () {
|
||||
it("shows a panel with no anchors in navy", function () {
|
||||
panelData.data.seismic_anchors = 0;
|
||||
panelData.data.wind_anchors = 0;
|
||||
|
||||
subject = new Panel(panelData);
|
||||
expect(graphicsSpy.beginFill).toHaveBeenCalledWith(Colors.default_background);
|
||||
});
|
||||
|
||||
it("shows the seismic anchors in yellow", function () {
|
||||
panelData.data.seismic_anchors = 2;
|
||||
panelData.data.wind_anchors = 0;
|
||||
|
||||
subject = new Panel(panelData);
|
||||
expect(graphicsSpy.beginFill).toHaveBeenCalledWith(Colors.seismic_background);
|
||||
});
|
||||
|
||||
it("shows the wind anchors in light-blue", function () {
|
||||
panelData.data.seismic_anchors = 0;
|
||||
panelData.data.wind_anchors = 1;
|
||||
|
||||
subject = new Panel(panelData);
|
||||
expect(graphicsSpy.beginFill).toHaveBeenCalledWith(Colors.wind_background);
|
||||
});
|
||||
|
||||
it("shows a panel with both wind and seismic anchors with a split color", function () {
|
||||
panelData.data.seismic_anchors = 1;
|
||||
panelData.data.wind_anchors = 2;
|
||||
|
||||
subject = new Panel(panelData);
|
||||
expect(graphicsSpy.beginFill).toHaveBeenCalledWith(Colors.wind_background);
|
||||
expect(graphicsSpy.beginFill).toHaveBeenCalledWith(Colors.seismic_background);
|
||||
});
|
||||
});
|
||||
|
||||
describe("selecting the panel", function () {
|
||||
beforeEach(function () {
|
||||
subject.select();
|
||||
});
|
||||
|
||||
it("marks the panel as selected", function () {
|
||||
expect(subject.selected).toBeTruthy();
|
||||
});
|
||||
|
||||
it("changes the background color", function () {
|
||||
expect(graphicsSpy.beginFill).toHaveBeenCalledWith('white');
|
||||
});
|
||||
});
|
||||
|
||||
describe("changing the overlay", function () {
|
||||
describe("to ANCHOR", function () {
|
||||
beforeEach(function () {
|
||||
subject.setOverlay("ANCHOR");
|
||||
});
|
||||
|
||||
it("shows the ballast information", function () {
|
||||
expect(subject.children).toContain(subject.textOverlays.ballast);
|
||||
expect(subject.textOverlays.ballast.text).toEqual(20);
|
||||
});
|
||||
|
||||
it("shows the sum of the anchor counts", function () {
|
||||
expect(subject.children).toContain(subject.textOverlays.anchors);
|
||||
expect(subject.textOverlays.anchors.text).toEqual(3);
|
||||
});
|
||||
|
||||
it("does not show the other information", function () {
|
||||
expect(subject.textOverlays.hasOwnProperty('panel_id')).toBeFalsy();
|
||||
expect(subject.textOverlays.hasOwnProperty('wind_anchors')).toBeFalsy();
|
||||
expect(subject.textOverlays.hasOwnProperty('seismic_anchors')).toBeFalsy();
|
||||
expect(subject.textOverlays.hasOwnProperty('wind_zones')).toBeFalsy();
|
||||
expect(subject.textOverlays.hasOwnProperty('cross_trays')).toBeFalsy();
|
||||
expect(subject.textOverlays.hasOwnProperty('link_trays')).toBeFalsy();
|
||||
expect(subject.textOverlays.hasOwnProperty('subarray')).toBeFalsy();
|
||||
expect(subject.textOverlays.hasOwnProperty('psf')).toBeFalsy();
|
||||
expect(subject.textOverlays.hasOwnProperty('panel_type')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("to ALL", function () {
|
||||
beforeEach(function () {
|
||||
subject.setOverlay("ALL");
|
||||
});
|
||||
|
||||
it("shows the panel_id information", function () {
|
||||
expect(subject.textOverlays.panel_id.text).toEqual(1);
|
||||
expect(subject.children).toContain(subject.textOverlays.panel_id);
|
||||
});
|
||||
|
||||
it("shows the ballast information", function () {
|
||||
expect(subject.children).toContain(subject.textOverlays.ballast);
|
||||
expect(subject.textOverlays.ballast.text).toEqual(20);
|
||||
});
|
||||
|
||||
it("shows the anchor information", function () {
|
||||
expect(subject.children).toContain(subject.textOverlays.wind_anchors);
|
||||
expect(subject.children).toContain(subject.textOverlays.seismic_anchors);
|
||||
expect(subject.textOverlays.wind_anchors.text).toEqual(2);
|
||||
expect(subject.textOverlays.seismic_anchors.text).toEqual('S');
|
||||
});
|
||||
|
||||
it("shows the wind zone information", function () {
|
||||
expect(subject.textOverlays.wind_zones.text).toEqual('C');
|
||||
expect(subject.children).toContain(subject.textOverlays.wind_zones);
|
||||
});
|
||||
|
||||
it("shows the cross trays information", function () {
|
||||
expect(subject.textOverlays.cross_trays.text).toEqual(1);
|
||||
expect(subject.children).toContain(subject.textOverlays.cross_trays);
|
||||
});
|
||||
|
||||
it("shows the link trays information", function () {
|
||||
expect(subject.textOverlays.link_trays.text).toEqual(1);
|
||||
expect(subject.children).toContain(subject.textOverlays.link_trays);
|
||||
});
|
||||
|
||||
it("shows the psf information", function () {
|
||||
expect(subject.textOverlays.psf.text).toEqual('3.24');
|
||||
expect(subject.children).toContain(subject.textOverlays.link_trays);
|
||||
});
|
||||
|
||||
it("shows the subarray information", function () {
|
||||
expect(subject.textOverlays.subarray.text).toEqual(5);
|
||||
expect(subject.children).toContain(subject.textOverlays.link_trays);
|
||||
});
|
||||
|
||||
it("shows the panel type information", function () {
|
||||
expect(subject.textOverlays.panel_type.text).toEqual(4);
|
||||
expect(subject.children).toContain(subject.textOverlays.panel_type);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
168
spec/javascripts/seismic_control_spec.js
Normal file
168
spec/javascripts/seismic_control_spec.js
Normal file
@@ -0,0 +1,168 @@
|
||||
import SeismicControl from '../../helix/javascript/array_summary/seismic_control';
|
||||
import $ from 'jquery';
|
||||
import 'jasmine-jquery';
|
||||
|
||||
describe('Seismic Control', function () {
|
||||
let htmlContent = '<div id="add_seismic" class="seismic_control"></div>' +
|
||||
'<div id="remove_seismic" class="seismic_control"></div>' +
|
||||
'<div id="save_seismic_changes" class="seismic_control"></div>' +
|
||||
'<div id="seismic_save" class="hidden">' +
|
||||
'<div class="seismic_save_message"></div>' +
|
||||
'<div class="dismiss_button"></div>' +
|
||||
'<div class="circle"></div>' +
|
||||
'</div>';
|
||||
let visualizationSpy;
|
||||
let subarrayDisplaySpy;
|
||||
let subject;
|
||||
|
||||
beforeEach(function () {
|
||||
setFixtures(htmlContent);
|
||||
visualizationSpy = jasmine.createSpyObj('arrayVisualization', ['addSeismicAnchor', 'removeSeismicAnchor', 'refreshPanels']);
|
||||
subarrayDisplaySpy = jasmine.createSpyObj('subarrayDisplay', ['didUpdateSubarrayData']);
|
||||
subject = new SeismicControl(visualizationSpy, subarrayDisplaySpy);
|
||||
subject.init($('*'), $("#seismic_save"));
|
||||
});
|
||||
|
||||
describe("clicking the add seismic anchor button", function () {
|
||||
beforeEach(function () {
|
||||
$("#add_seismic").click();
|
||||
});
|
||||
|
||||
it("tells the visualization to add a seismic anchor", function () {
|
||||
expect(visualizationSpy.addSeismicAnchor).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clicking the remove seismic anchor button", function () {
|
||||
beforeEach(function () {
|
||||
$("#remove_seismic").click();
|
||||
});
|
||||
|
||||
it("clicking the add seismic anchor button tells the visualization to remove a seismic anchor", function () {
|
||||
expect(visualizationSpy.removeSeismicAnchor).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clicking the save button", function () {
|
||||
let panelData = [{data: {panel_id: "foo", seismic_anchors: 0}}];
|
||||
let deferred;
|
||||
let receivedRequest;
|
||||
|
||||
beforeEach(function () {
|
||||
visualizationSpy.panelData = panelData;
|
||||
deferred = $.Deferred();
|
||||
spyOn($, 'ajax').and.callFake(function (request) {
|
||||
receivedRequest = request;
|
||||
return deferred.promise();
|
||||
});
|
||||
|
||||
$("#save_seismic_changes").click();
|
||||
});
|
||||
|
||||
it("sends an ajax request saving the panel data", function () {
|
||||
expect(receivedRequest).not.toBeUndefined();
|
||||
expect(receivedRequest.url).toEqual("/api/update_panel_data");
|
||||
expect(receivedRequest.data).toEqual(JSON.stringify([{panel_id: "foo", seismic_anchors: 0}]));
|
||||
expect(receivedRequest.method).toEqual("POST");
|
||||
});
|
||||
|
||||
describe("when the request succeeds", function () {
|
||||
let panelData = {foo: "bar"};
|
||||
let subarrayData = {baz: 'qux'};
|
||||
beforeEach(function () {
|
||||
deferred.resolve({status: "success", error: null, panel_data: panelData, subarray_data: subarrayData});
|
||||
});
|
||||
|
||||
it("informs the user of the success", function () {
|
||||
expect($("#seismic_save")).not.toHaveClass("hidden");
|
||||
expect($("#seismic_save")).toHaveClass("seismic_success");
|
||||
expect($(".seismic_save_message")).toHaveText("Changes to the Seismic Anchors have been successfully saved!");
|
||||
});
|
||||
|
||||
it("shows the ok icon in the banner", function () {
|
||||
expect($(".circle")).toHaveClass("icon-ok");
|
||||
expect($(".circle")).not.toHaveText("!");
|
||||
});
|
||||
|
||||
it("hides the banner again when the user clicks the dismiss button", function () {
|
||||
$(".dismiss_button").click();
|
||||
|
||||
expect($("#seismic_save")).toHaveClass("hidden");
|
||||
expect($("#seismic_save")).not.toHaveClass("seismic_success");
|
||||
});
|
||||
|
||||
it("tells the array visualization to reflash", function () {
|
||||
expect(visualizationSpy.refreshPanels).toHaveBeenCalledWith(panelData);
|
||||
});
|
||||
|
||||
it("informs the subarrayDisplay that we have new subarrayData", function () {
|
||||
expect(subarrayDisplaySpy.didUpdateSubarrayData).toHaveBeenCalledWith(subarrayData);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the request fails validation", function () {
|
||||
let subarrayData = {baz: 'qux'};
|
||||
beforeEach(function () {
|
||||
deferred.resolve({status: "error", error: "The validation failed", panel_data: null, subarray_data: subarrayData});
|
||||
});
|
||||
|
||||
it("shows the error", function () {
|
||||
expect($("#seismic_save")).not.toHaveClass("hidden");
|
||||
expect($("#seismic_save")).toHaveClass("seismic_error");
|
||||
expect($(".seismic_save_message")).toHaveText("The validation failed");
|
||||
});
|
||||
|
||||
it("shows the error icon in the banner", function () {
|
||||
expect($(".circle")).not.toHaveClass("icon-ok");
|
||||
expect($(".circle")).toHaveText("!");
|
||||
});
|
||||
|
||||
it("hides the banner again when the user clicks the dismiss button", function () {
|
||||
$(".dismiss_button").click();
|
||||
|
||||
expect($("#seismic_save")).toHaveClass("hidden");
|
||||
expect($("#seismic_save")).not.toHaveClass("seismic_error");
|
||||
});
|
||||
|
||||
it("does not tell the array visualization to reflash", function () {
|
||||
expect(visualizationSpy.refreshPanels).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("informs the subarrayDisplay that we have new subarrayData", function () {
|
||||
expect(subarrayDisplaySpy.didUpdateSubarrayData).toHaveBeenCalledWith(subarrayData);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the request fails otherwise", function () {
|
||||
beforeEach(function () {
|
||||
deferred.resolve({});
|
||||
});
|
||||
|
||||
it("shows the error", function () {
|
||||
expect($("#seismic_save")).not.toHaveClass("hidden");
|
||||
expect($("#seismic_save")).toHaveClass("seismic_error");
|
||||
expect($(".seismic_save_message")).toHaveText("Unknown error, please try again.");
|
||||
});
|
||||
|
||||
it("shows the error icon in the banner", function () {
|
||||
expect($(".circle")).not.toHaveClass("icon-ok");
|
||||
expect($(".circle")).toHaveText("!");
|
||||
});
|
||||
|
||||
it("hides the banner again when the user clicks the dismiss button", function () {
|
||||
$(".dismiss_button").click();
|
||||
|
||||
expect($("#seismic_save")).toHaveClass("hidden");
|
||||
expect($("#seismic_save")).not.toHaveClass("seismic_error");
|
||||
});
|
||||
|
||||
it("does not tell the array visualization to reflash", function () {
|
||||
expect(visualizationSpy.refreshPanels).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("informs the subarrayDisplay that we have new subarrayData", function () {
|
||||
expect(subarrayDisplaySpy.didUpdateSubarrayData).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
78
spec/javascripts/subarray_display_spec.js
Normal file
78
spec/javascripts/subarray_display_spec.js
Normal file
@@ -0,0 +1,78 @@
|
||||
import SubarrayDisplay from '../../helix/javascript/array_summary/subarray_display';
|
||||
import $ from 'jquery';
|
||||
import 'jasmine-jquery';
|
||||
|
||||
describe('Subarray Display', function () {
|
||||
let htmlContent = '<table class="summary_table">' +
|
||||
'<tr><th>Subarray</th><th>0</th><th>1</th></tr>' +
|
||||
'<tr id="needed_anchors"><th>Seismic Anchors Needed</th><td>0</td><td>0</td></tr>' +
|
||||
'<tr id="current_anchors"><th>Seismic Anchors Current</th><td>0</td><td>0</td></tr>' +
|
||||
'<tr id="subarray_weight"><th>Weight</th><td>0</td><td>0</td></tr>' +
|
||||
'</table>';
|
||||
|
||||
let panelData = [
|
||||
{'x': 1, 'y': 1, 'width': 1, 'height': 1, 'data': {'subarray': 0, 'seismic_anchors': 3}},
|
||||
{'x': 1, 'y': 2, 'width': 1, 'height': 1, 'data': {'subarray': 1, 'seismic_anchors': 2}},
|
||||
{'x': 1, 'y': 1, 'width': 1, 'height': 1, 'data': {'subarray': 1, 'seismic_anchors': 0}},
|
||||
{'x': 2, 'y': 1, 'width': 1, 'height': 1, 'data': {'subarray': 0, 'seismic_anchors': 1}},
|
||||
{'x': 2, 'y': 2, 'width': 1, 'height': 1, 'data': {'subarray': 0, 'seismic_anchors': 0}}
|
||||
];
|
||||
|
||||
let subject;
|
||||
|
||||
beforeEach(function () {
|
||||
setFixtures(htmlContent);
|
||||
let existingPanelData = [
|
||||
{'x': 1, 'y': 1, 'width': 1, 'height': 1, 'data': {'subarray': 0, 'seismic_anchors': 1}},
|
||||
{'x': 1, 'y': 2, 'width': 1, 'height': 1, 'data': {'subarray': 1, 'seismic_anchors': 1}},
|
||||
{'x': 1, 'y': 1, 'width': 1, 'height': 1, 'data': {'subarray': 1, 'seismic_anchors': 0}},
|
||||
{'x': 2, 'y': 1, 'width': 1, 'height': 1, 'data': {'subarray': 0, 'seismic_anchors': 1}},
|
||||
{'x': 2, 'y': 2, 'width': 1, 'height': 1, 'data': {'subarray': 0, 'seismic_anchors': 0}}
|
||||
];
|
||||
subject = new SubarrayDisplay();
|
||||
subject.init($('#current_anchors'), $('#needed_anchors'), $('#subarray_weight'), existingPanelData);
|
||||
});
|
||||
|
||||
it("updates the display table", function () {
|
||||
expect($('#current_anchors').find('td:nth-child(2)')).toHaveText(2);
|
||||
expect($('#current_anchors').find('td:nth-child(3)')).toHaveText(1);
|
||||
});
|
||||
|
||||
describe("when the seismic anchor count is modified", function () {
|
||||
beforeEach(function () {
|
||||
subject.didModifyPanels(panelData);
|
||||
});
|
||||
|
||||
it("updates the table row to show how many currently assigned seismic anchors there are", function () {
|
||||
expect($('#current_anchors').find('td:nth-child(2)')).toHaveText(4);
|
||||
expect($('#current_anchors').find('td:nth-child(3)')).toHaveText(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the other subarray data is modified", function () {
|
||||
beforeEach(function () {
|
||||
subject.didUpdateSubarrayData([
|
||||
{
|
||||
subarray: 0,
|
||||
weight: 971.53,
|
||||
required_seismic_anchors: 0
|
||||
},
|
||||
{
|
||||
subarray: 1,
|
||||
weight: 1000,
|
||||
required_seismic_anchors: 1
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it("updates the needed anchors row for the given subarrays", function () {
|
||||
expect($("#needed_anchors").find('td:nth-child(2)')).toHaveText(0);
|
||||
expect($("#needed_anchors").find('td:nth-child(3)')).toHaveText(1);
|
||||
});
|
||||
|
||||
it("updates the weight row for the given subarrays", function () {
|
||||
expect($("#subarray_weight").find('td:nth-child(2)')).toHaveText('971.53');
|
||||
expect($("#subarray_weight").find('td:nth-child(3)')).toHaveText('1,000');
|
||||
});
|
||||
});
|
||||
});
|
||||
3
spec/javascripts/test_index.js
Normal file
3
spec/javascripts/test_index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
// test_index.js
|
||||
var testsContext = require.context(".", true, /_spec.js$/);
|
||||
testsContext.keys().forEach(testsContext);
|
||||
206
spec/javascripts/zoom_control_spec.js
Normal file
206
spec/javascripts/zoom_control_spec.js
Normal file
@@ -0,0 +1,206 @@
|
||||
import ZoomControl from '../../helix/javascript/array_summary/zoom_control';
|
||||
import $ from 'jquery';
|
||||
import 'jasmine-jquery';
|
||||
|
||||
describe('Zoom Controls', function () {
|
||||
var htmlContent = '<div id="zoom_level"></div>';
|
||||
htmlContent += '<div id="decrease_zoom">-</div>';
|
||||
for (let i = 0; i < 7; i++) {
|
||||
htmlContent += '<div id="zoom_indicator_' + i + '"></div>';
|
||||
}
|
||||
htmlContent += '<div id="increase_zoom">+</div>';
|
||||
|
||||
var visualizationSpy = jasmine.createSpyObj('arrayVisualization', ['setZoom']);
|
||||
let subject;
|
||||
|
||||
beforeEach(function () {
|
||||
setFixtures(htmlContent);
|
||||
subject = new ZoomControl(visualizationSpy);
|
||||
subject.init($('*'));
|
||||
});
|
||||
|
||||
it("sets the default zoom", function () {
|
||||
expect(visualizationSpy.setZoom).toHaveBeenCalledWith(1);
|
||||
expect(subject.zoomLevel).toEqual(0);
|
||||
expect($("#zoom_indicator_0")).toHaveClass("zoom_active");
|
||||
expect($("#zoom_level")).toHaveText("0%");
|
||||
});
|
||||
|
||||
describe("clicking on the increase/decrease-zoom buttons", function () {
|
||||
beforeEach(function () {
|
||||
subject.setZoom(3, $('*'));
|
||||
});
|
||||
|
||||
describe("clicking the increase-zoom button", function () {
|
||||
beforeEach(function () {
|
||||
$("#increase_zoom").click();
|
||||
});
|
||||
|
||||
it("increases zoom by one level", function () {
|
||||
expect(visualizationSpy.setZoom).toHaveBeenCalledWith(5);
|
||||
});
|
||||
|
||||
it("changes the zoom_level stack", function () {
|
||||
expect($("#zoom_level")).toHaveText("67%");
|
||||
});
|
||||
|
||||
it("sets the zoom indicator properly", function () {
|
||||
expect($("#zoom_indicator_4")).toHaveClass("zoom_active");
|
||||
for (let i = 0; i < 7; i++) {
|
||||
if (i != 4) {
|
||||
expect($("#zoom_indicator_" + i)).not.toHaveClass("zoom_active");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
describe("clicking the decrease-zoom button", function () {
|
||||
beforeEach(function () {
|
||||
$("#decrease_zoom").click();
|
||||
});
|
||||
|
||||
it("decreases zoom by one level", function () {
|
||||
expect(visualizationSpy.setZoom).toHaveBeenCalledWith(3);
|
||||
});
|
||||
|
||||
it("changes the zoom_level stack", function () {
|
||||
expect($("#zoom_level")).toHaveText("33%");
|
||||
});
|
||||
|
||||
it("sets the zoom indicator properly", function () {
|
||||
expect($("#zoom_indicator_2")).toHaveClass("zoom_active");
|
||||
for (let i = 0; i < 7; i++) {
|
||||
if (i != 2) {
|
||||
expect($("#zoom_indicator_" + i)).not.toHaveClass("zoom_active");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when zoomed-out all the way", function () {
|
||||
beforeEach(function () {
|
||||
subject.setZoom(0, $('*'));
|
||||
});
|
||||
|
||||
describe("clicking the increase-zoom button", function () {
|
||||
beforeEach(function () {
|
||||
$("#increase_zoom").click();
|
||||
});
|
||||
|
||||
it("increases zoom by one level", function () {
|
||||
expect(visualizationSpy.setZoom).toHaveBeenCalledWith(2);
|
||||
});
|
||||
|
||||
it("changes the zoom_level stack", function () {
|
||||
expect($("#zoom_level")).toHaveText("17%");
|
||||
});
|
||||
|
||||
it("sets the zoom indicator properly", function () {
|
||||
expect($("#zoom_indicator_1")).toHaveClass("zoom_active");
|
||||
for (let i = 0; i < 7; i++) {
|
||||
if (i != 1) {
|
||||
expect($("#zoom_indicator_" + i)).not.toHaveClass("zoom_active");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("clicking the decrease-zoom button", function () {
|
||||
beforeEach(function () {
|
||||
$("#decrease_zoom").click();
|
||||
});
|
||||
|
||||
it("does nothing", function () {
|
||||
expect(visualizationSpy.setZoom).not.toHaveBeenCalledWith(0);
|
||||
});
|
||||
|
||||
it("does not change the zoom_level stack", function () {
|
||||
expect($("#zoom_level")).toHaveText("0%");
|
||||
});
|
||||
|
||||
it("does not change the zoom indicator", function () {
|
||||
expect($("#zoom_indicator_0")).toHaveClass("zoom_active");
|
||||
for (let i = 0; i < 7; i++) {
|
||||
if (i != 0) {
|
||||
expect($("#zoom_indicator_" + i)).not.toHaveClass("zoom_active");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when zoomed-in all the way", function () {
|
||||
beforeEach(function () {
|
||||
subject.setZoom(6, $('*'));
|
||||
});
|
||||
|
||||
describe("clicking the increase-zoom button", function () {
|
||||
beforeEach(function () {
|
||||
$("#increase_zoom").click();
|
||||
});
|
||||
|
||||
it("does nothing", function () {
|
||||
expect(visualizationSpy.setZoom).not.toHaveBeenCalledWith(8);
|
||||
});
|
||||
|
||||
it("changes the zoom_level stack", function () {
|
||||
expect($("#zoom_level")).toHaveText("100%");
|
||||
});
|
||||
|
||||
it("does not change the zoom indicator", function () {
|
||||
expect($("#zoom_indicator_6")).toHaveClass("zoom_active");
|
||||
for (let i = 0; i < 7; i++) {
|
||||
if (i != 6) {
|
||||
expect($("#zoom_indicator_" + i)).not.toHaveClass("zoom_active");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("clicking the decrease-zoom button", function () {
|
||||
beforeEach(function () {
|
||||
$("#decrease_zoom").click();
|
||||
});
|
||||
|
||||
it("decreases the zoom by one level", function () {
|
||||
expect(visualizationSpy.setZoom).toHaveBeenCalledWith(6);
|
||||
});
|
||||
|
||||
it("changes the zoom_level stack", function () {
|
||||
expect($("#zoom_level")).toHaveText("83%");
|
||||
});
|
||||
|
||||
it("does not change the zoom indicator properly", function () {
|
||||
expect($("#zoom_indicator_5")).toHaveClass("zoom_active");
|
||||
for (let i = 0; i < 7; i++) {
|
||||
if (i != 5) {
|
||||
expect($("#zoom_indicator_" + i)).not.toHaveClass("zoom_active");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("clicking on one of the zoom-indicator buttons", function () {
|
||||
beforeEach(function () {
|
||||
$("#zoom_indicator_4").click();
|
||||
});
|
||||
|
||||
it("goes directly to that zoom level", function () {
|
||||
expect(visualizationSpy.setZoom).toHaveBeenCalledWith(5);
|
||||
});
|
||||
|
||||
it("changes the zoom_level stack", function () {
|
||||
expect($("#zoom_level")).toHaveText("67%");
|
||||
});
|
||||
|
||||
it("sets the zoom indicator properly", function () {
|
||||
expect($("#zoom_indicator_4")).toHaveClass("zoom_active");
|
||||
for (let i = 0; i < 7; i++) {
|
||||
if (i != 4) {
|
||||
expect($("#zoom_indicator_" + i)).not.toHaveClass("zoom_active");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user