Skip to content

Commit

Permalink
Add travis and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Moutard committed May 30, 2019
1 parent 82de276 commit ab40bbc
Show file tree
Hide file tree
Showing 5 changed files with 3,159 additions and 44 deletions.
6 changes: 4 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
"browser": true,
"node": true,
"es6": true,
"jest": true,
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 6,
}
"ecmaVersion": 8,
},
"plugins": ["jest"]
}
18 changes: 18 additions & 0 deletions lib/__tests__/sepa.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const Sepa = require('../sepa');

const SEPA_TYPE = 'pain.001.001.03'; // Customer Credit Transfer Initiation V3

describe('SEPA lib', () => {

it('should build a valid simple sepa XML', async () => {
const doc = new Sepa.Document(SEPA_TYPE);

doc.grpHdr.id = 'ID_1';
doc.grpHdr.created = new Date();
doc.grpHdr.initiatorName = 'SPENDESK';
const xmlString = doc.toString();
expect(xmlString).toMatch(/<\?xml version="1.0" encoding="UTF-8"\?>/);
// Correctly build the initiatorName
expect(xmlString).toMatch(/SPENDESK/);
});
});
2 changes: 1 addition & 1 deletion lib/sepa.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@
*/
function serializeToString(doc) {
var s;
if (typeof window === 'undefined') {
if (typeof window === 'undefined' || typeof window.XMLSerializer === 'undefined') {
var XMLSerializer = require('xmldom').XMLSerializer;
s = new XMLSerializer();
} else {
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@
"lint"
],
"scripts": {
"lint": "./node_modules/.bin/eslint ."
"lint": "./node_modules/.bin/eslint .",
"version": "npm run build",
"postversion": "git push && git push --tags",
"test": "jest"
},
"dependencies": {
"xmldom": "*"
},
"devDependencies": {
"eslint": "*",
"eslint-plugin-jest": "^22.6.4",
"jest": "^24.8.0",
"pre-commit": "*",
"uglify-js": "^3.3.20"
},
Expand Down
Loading

0 comments on commit ab40bbc

Please sign in to comment.