-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reject forms which do not have <instanceID>
Closes #112
- Loading branch information
alxndrsn
committed
Dec 10, 2018
1 parent
f8ddb6c
commit 8b51f74
Showing
6 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = (promiseChain, message) => | ||
promiseChain.then(() => { | ||
throw new Error(message); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
test/data/lib/upload-forms/no-instance-id/forms/example.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0"?> | ||
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<h:head> | ||
<h:title>No Instance ID</h:title> | ||
<model> | ||
<instance> | ||
<data id="ABC" version="2015-06-05"> | ||
<name/> | ||
</data> | ||
</instance> | ||
<bind nodeset="/data/name" type="string" /> | ||
</model> | ||
</h:head> | ||
<h:body> | ||
<input ref="/data/name"> | ||
<label>What is the name?</label> | ||
</input> | ||
</h:body> | ||
</h:html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const assert = require('chai').assert; | ||
const uploadForms = require('../../src/lib/upload-forms'); | ||
|
||
const BASE_DIR = 'data/lib/upload-forms'; | ||
const COUCH_URL = 'http://example.com/db-name'; | ||
const FORMS_SUBDIR = '.'; | ||
|
||
describe('upload-forms', function() { | ||
it('should reject forms which do not have <meta><instanceID/></meta>', function() { | ||
|
||
// when | ||
return uploadForms(`${BASE_DIR}/no-instance-id`, COUCH_URL, FORMS_SUBDIR) | ||
|
||
.then(() => assert.fail('Expected Error to be thrown.')) | ||
|
||
.catch(e => { | ||
assert.include(e.message, 'This form will not work on medic-webapp.'); | ||
}); | ||
}); | ||
}); |