forked from dimagi/Vellum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexporter.js
70 lines (66 loc) · 2.56 KB
/
exporter.js
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
/*jshint multistr: true */
require([
'chai',
'jquery',
'underscore',
'tests/utils',
'text!static/all_question_types.xml',
'text!static/all_question_types.tsv',
'text!static/exporter/item-id.xml',
'text!static/exporter/item-id.tsv'
], function (
chai,
$,
_,
util,
ALL_QUESTIONS_XML,
ALL_QUESTIONS_TSV,
item_id_xml,
item_id_tsv
) {
var assert = chai.assert,
call = util.call;
describe("The exporter", function () {
beforeEach(function (done) {
util.init({
core: {
onReady: function () {
done();
}
}
});
});
it("should include question type in TSV", function () {
call("loadXML", ALL_QUESTIONS_XML);
assert.equal(call("getData").core.form.getExportTSV(), ALL_QUESTIONS_TSV);
});
it("should include item values in TSV", function () {
call("loadXML", item_id_xml);
assert.equal(call("getData").core.form.getExportTSV(), item_id_tsv);
});
});
// TODO test with newlines (should they be preserved? old vellum did not)
// var TEST_XML_1 = util.xmlines('' +
// '<?xml version="1.0" encoding="UTF-8"?>\
// <h:html xmlns:h="http://www.w3.org/1999/xhtml" xmlns:orx="http://openrosa.org/jr/xforms" xmlns="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa" xmlns:vellum="http://commcarehq.org/xforms/vellum">\
// <h:head>\
// <h:title>Untitled Form</h:title>\
// <model>\
// <instance>\
// <data xmlns:jrm="http://dev.commcarehq.org/jr/xforms" xmlns="http://openrosa.org/formdesigner/398C9010-61DC-42D3-8A85-B857AC3A9CA0" uiVersion="1" version="1" name="Untitled Form">\
// <question1 />\
// </data>\
// </instance>\
// <bind nodeset="/data/question1" calculate="concat("Line 1"," Line 2")" />\
// <itext>\
// <translation lang="en" default=""/>\
// </itext>\
// </model>\
// </h:head>\
// <h:body></h:body>\
// </h:html>');
//
// var TEST_TSV_2 = ('' +
// 'Question Type Text (en) Text (hin) Audio (en) Audio (hin) Image (en) Image (hin) Display Condition Validation Condition Validation Message Calculate Condition Required\n' +
// '/data/question1 Hidden Value concat("Line 1"," Line 2") no');
});