Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sudo: false
language: node_js
node_js:
- "4"
before_script:
- npm install -g grunt-cli
16 changes: 16 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ module.exports = function(grunt) {
src: 'dist/xpathjs.js',
dest: 'dist/xpathjs.min.js'
}
},

karma: {
options: {
singleRun: true,
reporters: ['dots']
},
headless: {
configFile: 'test/karma.conf.js',
browsers: ['PhantomJS']
},
browsers: {
configFile: 'test/karma.conf.js',
browsers: ['Chrome', 'Firefox', 'Safari', 'Opera']
}
}
});

Expand All @@ -45,6 +60,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-peg');
grunt.loadNpmTasks('grunt-karma');

grunt.registerTask('dist', [
'clean:dist',
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,8 @@ cd xpathjs
npm install
grunt dist
```

Test
----------

Run tests headlessly with `grunt karma:headless` and in browsers with `grunt karma:browsers`.
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,29 @@

"license": "AGPL-3.0",

"scripts": {
"test": "grunt karma:headless"
},

"repository": {
"type": "git",
"url": "https://github.com/andrejpavlovic/xpathjs.git"
},

"devDependencies": {
"chai": "^2.1.1",
"grunt": "~0.4.5",
"grunt-karma": "^0.10.1",
"grunt-mocha-test": "^0.12.7",
"karma": "^0.12.31",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^0.1.7",
"karma-firefox-launcher": "^0.1.4",
"karma-mocha": "^0.1.10",
"karma-opera-launcher": "^0.1.0",
"karma-phantomjs-launcher": "^0.1.4",
"karma-safari-launcher": "^0.1.1",
"mocha": "^2.1.0",
"grunt-contrib-clean": "1.0.0",
"grunt-contrib-concat": "1.0.0",
"grunt-contrib-uglify": "0.11.1",
Expand Down
68 changes: 34 additions & 34 deletions tests/tests.php → test/doc.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,10 @@
<?php
/**
* Copyright (C) 2011 Andrej Pavlovic
*
* This file is part of XPathJS.
*
* XPathJS is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* XPathJS is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

$serve_xml = !empty($_GET['xml']);

if ($serve_xml)
header('Content-Type: application/xhtml+xml');
?>
<!DOCTYPE html>
<!-- some comment -->
<html xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://some-namespace.com/nss">
<html xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://some-namespace.com/nss" version="1a">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>xpath-test</title>
</head>
<body class="yui3-skin-sam">
<body class="yui3-skin-sam" id="body">
<div id="testXPathNSResolver">
<div id="testXPathNSResolverNode" xmlns:xforms="http://www.w3.org/2002/xforms">
<div xmlns="http://www.w3.org/TR/REC-html40">
Expand Down Expand Up @@ -66,13 +41,28 @@
<p>3</p>
<p>4</p>
</div>

<div id="testFunctionNodeset3">
<div>
<p>1</p>
</div>
<div>
<p id="testFunctionNodeset3NodeP">2</p>
</div>
<div>
<p>3</p>
</div>
<div>
<p>4</p>
</div>
</div>

<div id="testFunctionNodesetElement">aaa</div>
<div id="testFunctionNodesetElementPrefix"><ev:div2></ev:div2></div>
<div id="testFunctionNodesetElementNested"><span>bbb</span>sss<span></span><div>ccc<span>ddd</span></div></div>
<div id="testFunctionNodesetComment"><!-- hello world --></div>
<div id="testFunctionNodesetText">here is some text</div>
<div id="testFunctionNodesetProcessingInstruction"><?php echo '<?xml-stylesheet type="text/xml" href="test.xsl"?>' ?></div>
<div id="testFunctionNodesetProcessingInstruction"><?xml-stylesheet type="text/xml" href="test.xsl"?></div>
<div id="testFunctionNodesetCData"><![CDATA[some cdata]]></div>
<div id="testFunctionNodesetAttribute" ev:class="123" width=" 1 00% "></div>
<div id="testFunctionNodesetNamespace" xmlns:asdf="http://www.123.com/"></div>
Expand All @@ -83,7 +73,7 @@
<div id="FunctionStringCaseStringNodesetElementNested"><span>bbb</span>sss<span></span><div>ccc<span>ddd</span></div></div>
<div id="FunctionStringCaseStringNodesetComment"><!-- hello world --></div>
<div id="FunctionStringCaseStringNodesetText">here is some text</div>
<div id="FunctionStringCaseStringNodesetProcessingInstruction"><?php echo '<?xml-stylesheet type="text/xml" href="test.xsl"?>' ?></div>
<div id="FunctionStringCaseStringNodesetProcessingInstruction"><?xml-stylesheet type="text/xml" href="test.xsl"?></div>
<div id="FunctionStringCaseStringNodesetCData"><![CDATA[some cdata]]></div>
<div id="FunctionStringCaseStringNodesetAttribute" class="123" width=" 1 00% "></div>
<div id="FunctionStringCaseStringNodesetNamespace" xmlns:asdf="http://www.123.com/"></div>
Expand Down Expand Up @@ -117,18 +107,28 @@
<div id="testContextNodeParameterText">some text</div>
<div id="testContextNodeParameterCData"><![CDATA[aa<strong>some text</strong>]]></div>
<div id="testContextNodeParameterComment"><!-- here is comment --></div>
<div id="testContextNodeParameterProcessingInstruction"><?php echo '<?xml-stylesheet type="text/xml" href="test.xsl"?>' ?></div>
<div id="testContextNodeParameterProcessingInstruction"><?xml-stylesheet type="text/xml" href="test.xsl"?></div>
<div id="testContextNodeParameterNamespace" xmlns:asdf="http://some-namespace/"></div>
</div>
</div>

<div id="FunctionBooleanEmptyNode">
<div></div>
</div>

<div id="FunctionSumCaseJavarosa">
<div>-10</div>
<div>15</div>
<div></div>
</div>

<div id="StepAxisCase">

<div id="testStepAxisNodeElement"></div>
<div id="testStepAxisNodeAttribute" style="sss:asdf;" width="100%"></div>
<div id="testStepAxisNodeCData"><![CDATA[aa<strong>some text</strong>]]><div></div>asdf</div>
<div id="testStepAxisNodeComment"><!-- here is comment --><div></div>asdf</div>
<div id="testStepAxisNodeProcessingInstruction"><?php echo '<?xml-stylesheet type="text/xml" href="test.xsl"?>' ?><div></div>asdf</div>
<div id="testStepAxisNodeProcessingInstruction"><?xml-stylesheet type="text/xml" href="test.xsl"?><div></div>asdf</div>
<div id="testStepAxisNodeNamespace" xmlns:asdf="http://some-namespace/" width="100%"></div>

<div id="testStepAxisChild">
Expand Down Expand Up @@ -206,13 +206,13 @@
asdf
asdfsdf sdf
<div></div>
<?php echo '<?xml-stylesheet type="text/xml" href="test.xsl"?>' ?>
<?xml-stylesheet type="text/xml" href="test.xsl"?>
<div></div>
sdfsdf
<![CDATA[aa<strong>some text</strong>]]>
<!-- comment -->
<div></div>
<?php echo '<?custom-process-instruct type="text/xml" href="test.xsl"?>' ?>
<?custom-process-instruct type="text/xml" href="test.xsl"?>
<div></div>
</div>

Expand Down Expand Up @@ -244,7 +244,7 @@
<div id="LocationPathCaseText">some text</div>
<div id="LocationPathCaseComment"><!-- some comment --></div>
<div id="LocationPathCaseCData"><![CDATA[some cdata]]></div>
<div id="LocationPathCaseProcessingInstruction"><?php echo '<?xml-stylesheet type="text/xml" href="test.xsl"?>' ?></div>
<div id="LocationPathCaseProcessingInstruction"><?xml-stylesheet type="text/xml" href="test.xsl"?></div>
<div id="LocationPathCaseAttribute" class="123" width="100%"></div>
<div id="LocationPathCaseNamespace" xmlns:asdf="http://www.123.com/"></div>

Expand Down
Loading