diff options
author | jakefeasel <jfeasel@gmail.com> | 2012-09-30 23:39:51 -0700 |
---|---|---|
committer | jakefeasel <jfeasel@gmail.com> | 2012-09-30 23:39:51 -0700 |
commit | cc1ee5fd51d714da796a34453d3d336f4a0cfa30 (patch) | |
tree | 60f9285900625530504d7cd20f99ff00eac71c61 | |
parent | 015c06e74f03f497383dcf2fab3ab57a784f4869 (diff) | |
download | DDLBuilder-cc1ee5fd51d714da796a34453d3d336f4a0cfa30.zip DDLBuilder-cc1ee5fd51d714da796a34453d3d336f4a0cfa30.tar.gz DDLBuilder-cc1ee5fd51d714da796a34453d3d336f4a0cfa30.tar.bz2 |
Improved messaging, error handling
-rw-r--r-- | ddl_builder/qunit/guessValueSeparators.js | 2 | ||||
-rw-r--r-- | ddl_builder/qunit/main.js | 2 | ||||
-rw-r--r-- | ddl_builder/qunit/recordCount.js | 14 |
3 files changed, 12 insertions, 6 deletions
diff --git a/ddl_builder/qunit/guessValueSeparators.js b/ddl_builder/qunit/guessValueSeparators.js index 59a4f50..c118837 100644 --- a/ddl_builder/qunit/guessValueSeparators.js +++ b/ddl_builder/qunit/guessValueSeparators.js @@ -8,7 +8,7 @@ define(["jQuery","QUnit", "DDLBuilder/ddl_builder"], function ($,QUnit,DDLBuilde if (result.separator) QUnit.equal(ddl_builder.guessValueSeparator($("#" + id).html()).separator.toString(), sep.toString(), "Guessing Value Separators"); else - QUnit.ok(false, "Guess failed with message:" + result.message); + QUnit.ok(false, "Guessing value separators failed with message:" + result.message); }; diff --git a/ddl_builder/qunit/main.js b/ddl_builder/qunit/main.js index 8abd0a7..aba2ec9 100644 --- a/ddl_builder/qunit/main.js +++ b/ddl_builder/qunit/main.js @@ -16,7 +16,7 @@ define([ $("#qunit-fixture #ddlInputText span").each(function () { var $this = $(this); - QUnit.test("Parsing " + this.id, function () { + QUnit.test("Parsing " + $this.attr('id'), function () { columnTypes($this.attr('id'), $this.attr('types')); guessValueSeparators($this.attr('id'), $this.attr('valueSeparator')); headerNames($this.attr('id'), $this.attr('headers')); diff --git a/ddl_builder/qunit/recordCount.js b/ddl_builder/qunit/recordCount.js index 90791a5..0ec59fd 100644 --- a/ddl_builder/qunit/recordCount.js +++ b/ddl_builder/qunit/recordCount.js @@ -2,11 +2,17 @@ define(["jQuery","QUnit", "DDLBuilder/ddl_builder"], function ($,QUnit,DDLBuilde return function (id,count) { var ddl_builder = new DDLBuilder({ddlTemplate: "[{{#each_with_index data}}{{#if index}},{{/if}}}{{index}}{{/each_with_index}}}]"}); - var result = ddl_builder.parse($("#" + id).html()); - if ($.parseJSON(result)) - QUnit.equal($.parseJSON(result).length, count, "Getting Record Count"); + var result = ddl_builder.parse($("#" + id).html()), + parsedResult = false; + + try { + parsedResult = $.parseJSON(result); + } catch (err){} + + if (parsedResult) + QUnit.equal(parsedResult.length, count, "Getting Record Count"); else - QUnit.ok(false, "Unable to parse result to JSON array ("+ result +")"); + QUnit.ok(false, "Getting Record Count failed: Unable to parse result to JSON array ("+ result +")"); }; }); |