Skip to content

Commit 8702172

Browse files
committed
palatableXML() helper and example callsite
1 parent 58c1036 commit 8702172

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

test/data/test-xml.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ function isPalatableXML(allegedXML) {
3030
if (xmlDoc.validationErrors.length) {
3131
throw new Error(`Validation errors:\n${xmlDoc.validationErrors.join('\n')}`);
3232
}
33+
return true;
34+
}
35+
36+
export default function palatableXML(allegedXML) {
37+
isPalatableXML(allegedXML);
38+
return allegedXML;
3339
}
3440

3541
describe('Validity of form testdata XML', () => {

test/integration/other/form-entities-version.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ const config = require('config');
44
const appRoot = require('app-root-path');
55
const { testService } = require('../setup');
66
const testData = require('../../data/xml');
7+
const palatableXML = require('../../data/test-xml');
78

89
const { exhaust } = require(appRoot + '/lib/worker/worker');
910

10-
const upgradedUpdateEntity = `<?xml version="1.0"?>
11+
const upgradedUpdateEntity = palatableXML(`<?xml version="1.0"?>
1112
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:entities="http://www.opendatakit.org/entities" xmlns:orx="http://openrosa.org/xforms">
1213
<h:head>
1314
<model entities:entities-version="2024.1.0">
@@ -27,9 +28,9 @@ const upgradedUpdateEntity = `<?xml version="1.0"?>
2728
<bind nodeset="/data/age" type="int" entities:saveto="age"/>
2829
</model>
2930
</h:head>
30-
</h:html>`;
31+
</h:html>`);
3132

32-
const upgradedSimpleEntity = `<?xml version="1.0"?>
33+
const upgradedSimpleEntity = palatableXML(`<?xml version="1.0"?>
3334
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:entities="http://www.opendatakit.org/entities" xmlns:orx="http://openrosa.org/xforms">
3435
<h:head>
3536
<model entities:entities-version="2024.1.0">
@@ -50,7 +51,7 @@ const upgradedSimpleEntity = `<?xml version="1.0"?>
5051
<bind nodeset="/data/hometown" type="string"/>
5152
</model>
5253
</h:head>
53-
</h:html>`;
54+
</h:html>`);
5455

5556
describe('Update / migrate entities-version within form', () => {
5657
describe('upgrading a 2023.1.0 update form', () => {

0 commit comments

Comments
 (0)