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
|
define([
"jQuery",
"QUnit",
"text!./fixture.html",
"./columnTypes",
"./guessValueSeparators",
"./headerNames",
"./recordCount",
"DDLBuilder/ddl_builder"
],
function ($,QUnit,fixtureContent,
columnTypes,guessValueSeparators,
headerNames,recordCount,
DDLBuilder) {
$("#qunit-fixture").append(fixtureContent);
$("#qunit-fixture #ddlInputText span").each(function () {
var $this = $(this);
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'));
recordCount($this.attr('id'), $this.attr('recordCount'));
});
});
QUnit.test("Various date format parsing attempts", function () {
var content = $("#qunit-fixture #dateParse").html(),
ddl_builder = new DDLBuilder({ddlTemplate: "[{{#each_with_index data}}{{#if index}},{{/if}}[{{#each_with_index r}}{{#if index}}, {{/if}}\"{{formatted_field ../..}}\"{{/each_with_index}}]{{/each_with_index}}]"}),
result = ddl_builder.parse(content),
parsedResult=null,i=0;
try {
parsedResult = $.parseJSON(result);
} catch (err){}
if (parsedResult) {
for (i in parsedResult) {
QUnit.equal(parsedResult[i][0], parsedResult[i][1], "Input date matches output date");
}
}
else
QUnit.ok(false, "Reading date data failed: Unable to parse result to JSON array ("+ result +")");
});
}
);
|