summaryrefslogtreecommitdiff
path: root/jarmon
diff options
context:
space:
mode:
authorRichard Wall <richard@largo>2010-12-30 18:15:15 +0000
committerRichard Wall <richard@largo>2010-12-30 18:15:15 +0000
commitcc1d4b25ed125afd07204da980f5c9bc555b7862 (patch)
tree530a62b6d16f955da3086a799190d60e9af765cb /jarmon
parentb3dfd26ce97cd1817f728667a586bf29eace752f (diff)
Render an error message and a list of ds label fields
Diffstat (limited to 'jarmon')
-rw-r--r--jarmon/jarmon.js10
-rw-r--r--jarmon/jarmon.test.js43
2 files changed, 45 insertions, 8 deletions
diff --git a/jarmon/jarmon.js b/jarmon/jarmon.js
index c25210d..ae452d3 100644
--- a/jarmon/jarmon.js
+++ b/jarmon/jarmon.js
@@ -702,14 +702,18 @@ jarmon.ChartConfig.prototype.draw = function() {
this.$tpl.empty();
$(this.errors).map(function(i, el) {
- return $('<p/>').text(el.toString());
+ return $('<p/>', {'class': 'error'}).text(el.toString());
}).appendTo(this.$tpl);
var $f = $('<form/>')
$('<div/>').append(
$('<label/>').append(
['URL', ': '].join(''),
- $('<input/>', {name: 'rrd_url', value: this.rrdUrl})
+ $('<input/>', {
+ type: 'text',
+ name: 'rrd_url',
+ value: this.rrdUrl
+ })
)
).appendTo($f);
@@ -717,7 +721,7 @@ jarmon.ChartConfig.prototype.draw = function() {
return $('<label/>').append(
[el, ': '].join(''),
$('<input/>', {
- type: 'checkbox',
+ type: 'text',
name: 'rrd_ds',
value: el
})
diff --git a/jarmon/jarmon.test.js b/jarmon/jarmon.test.js
index 7f34391..0e548d5 100644
--- a/jarmon/jarmon.test.js
+++ b/jarmon/jarmon.test.js
@@ -403,13 +403,46 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) {
Y.Test.Runner.add(new Y.Test.Case({
name: "jarmon.ChartConfig",
- test_draw: function () {
+ setUp: function() {
+ this.$tpl = $('<div/>').appendTo($('body'))
+ var c = new jarmon.ChartConfig(this.$tpl);
+ c.draw();
+ },
+
+ test_drawInitialForm: function () {
/**
- * Test that a rendered chart has the correct dimensions, legend,
- * axis, labels etc
+ * Test that the initial config form contains an rrd form field
**/
- var c = new jarmon.ChartConfig($('<div/>').appendTo($('body')));
- c.draw();
+ Y.Assert.areEqual(
+ this.$tpl.find('form input[name=rrd_url]').size(), 1);
+ },
+
+ test_drawUrlErrorMessage: function () {
+ /**
+ * Test that submitting the form with an incorrect url results in
+ * an error message
+ **/
+ var self = this;
+ this.$tpl.find('form input[name=rrd_url]').val('Foo/Bar').submit();
+ this.wait(
+ function() {
+ Y.Assert.areEqual(self.$tpl.find('.error').size(), 1);
+ }, 1000
+ );
+ },
+
+ test_drawUrlListDatasources: function () {
+ /**
+ * Test that submitting the form with an correct rrd url results in
+ * list of further DS label fields
+ **/
+ var self = this;
+ this.$tpl.find('form input[name=rrd_url]').val('build/test.rrd').submit();
+ this.wait(
+ function() {
+ Y.Assert.areEqual(self.$tpl.find('input[name=rrd_ds]').size(), 1);
+ }, 1000
+ );
},
}));