-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add executable example for NodeJs
- Loading branch information
Showing
6 changed files
with
81 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This workflow will run the examples provided in the examples folder | ||
name: examples | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
nodejs: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: | ||
- 10.x | ||
- 12.x | ||
- 14.x | ||
- 16.x | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
working-directory: examples/nodejs | ||
- run: npm run test | ||
working-directory: examples/nodejs |
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,2 @@ | ||
node_modules | ||
package-lock.json |
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 @@ | ||
package-lock=false |
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 @@ | ||
{ | ||
"name": "@xmldom/xmldom-example-nodejs", | ||
"private": true, | ||
"description": "Show how to use xmldom in a nodejs project", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "node src/index.js" | ||
}, | ||
"keywords": [ | ||
"test", | ||
"commonjs", | ||
"nodejs" | ||
], | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@xmldom/xmldom": "file:../.." | ||
} | ||
} |
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,15 @@ | ||
const { DOMParser, XMLSerializer } = require('@xmldom/xmldom') | ||
|
||
const source = `<xml xmlns="a"> | ||
<child>test</child> | ||
<child/> | ||
</xml>` | ||
|
||
const doc = new DOMParser().parseFromString(source, 'text/xml') | ||
|
||
const serialized = new XMLSerializer().serializeToString(doc) | ||
|
||
if (source !== serialized) { | ||
console.error(`expected\n${source}\nbut was\n${serialized}`) | ||
process.exit(1); | ||
} |
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