diff options
-rw-r--r-- | jarmon/jarmon.js | 10 | ||||
-rw-r--r-- | jarmon/jarmon.test.js | 43 | ||||
-rw-r--r-- | test.html | 5 |
3 files changed, 46 insertions, 12 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 + ); }, })); @@ -3,10 +3,7 @@ <head> <meta charset="utf-8"> <title>Jarmon Unit Test Runner</title> - <link rel="stylesheet" type="text/css" - href="http://developer.yahoo.com/yui/3/assets/yui.css"/> - <link rel="stylesheet" type="text/css" - href="http://yui.yahooapis.com/3.1.1/build/cssfonts/fonts-min.css"/> + <style type='text/css'> .chart { width: 500px; |