/usr/share/maas/web/static/js/tests/test_nodes_chart.js is in maas-region-controller-min 1.5+bzr2252-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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /* Copyright 2012 Canonical Ltd. This software is licensed under the
* GNU Affero General Public License version 3 (see the file LICENSE).
*/
YUI({ useBrowserConsole: true }).add('maas.nodes_chart.tests', function(Y) {
Y.log('loading maas.nodes_chart.tests');
var namespace = Y.namespace('maas.nodes_chart.tests');
var module = Y.maas.nodes_chart;
var suite = new Y.Test.Suite("maas.nodes_chart Tests");
var cfg = {
node_id: 'chart',
width: 300,
allocated_nodes: 5,
commissioned_nodes: 6,
queued_nodes: 2,
offline_nodes: 3,
added_nodes: 10
};
suite.add(new Y.maas.testing.TestCase({
name: 'test-nodes-chart-widget-creation',
setUp : function () {
this.chart = new module.NodesChartWidget(cfg);
},
testCreation: function() {
Y.assert(
Y.one('#chart').get('text'),
'The target node should be populated with the chart');
// Check we created the svg nodes
Y.assert(this.chart._outer_paths[0].node);
Y.assert(this.chart._outer_paths[1].node);
Y.assert(this.chart._outer_paths[2].node);
Y.assert(this.chart._offline_circle[0].node);
Y.assert(this.chart._added_circle[0].node);
},
tearDown : function () {
Y.one('#chart').set('text', '');
}
}));
suite.add(new Y.maas.testing.TestCase({
name: 'test-nodes-chart-events',
setUp : function () {
this.chart = new module.NodesChartWidget(cfg);
},
testWidgetHover: function() {
var events = [
{
event: 'hover.allocated.over',
action: 'mouseover',
fired: false,
node: this.chart._outer_paths[0].node
},
{
event: 'hover.allocated.out',
action: 'mouseout',
fired: false,
node: this.chart._outer_paths[0].node
},
{
event: 'hover.commissioned.over',
action: 'mouseover',
fired: false,
node: this.chart._outer_paths[1].node
},
{
event: 'hover.commissioned.out',
action: 'mouseout',
fired: false,
node: this.chart._outer_paths[1].node
},
{
event: 'hover.queued.over',
action: 'mouseover',
fired: false,
node: this.chart._outer_paths[2].node
},
{
event: 'hover.queued.out',
action: 'mouseout',
fired: false,
node: this.chart._outer_paths[2].node
},
{
event: 'hover.offline.over',
action: 'mouseover',
fired: false,
node: this.chart._offline_circle[0].node
},
{
event: 'hover.offline.out',
action: 'mouseout',
fired: false,
node: this.chart._offline_circle[0].node
},
{
event: 'hover.added.over',
action: 'mouseover',
fired: false,
node: this.chart._added_circle[0].node
},
{
event: 'hover.added.out',
action: 'mouseout',
fired: false,
node: this.chart._added_circle[0].node
}
];
Y.Array.each(events, function(event) {
this.chart.on(event.event, function(e, event) {
event.fired = true;
}, null, event);
Y.one(event.node).simulate(event.action);
Y.Assert.isTrue(
event.fired,
'Event ' + event.event + ' should have fired');
}, this);
},
tearDown : function () {
Y.one('#chart').set('text', '');
}
}));
namespace.suite = suite;
}, '0.1', {'requires': [
'node-event-simulate', 'test', 'maas.testing', 'maas.nodes_chart']}
);
|