Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
rewrite tests to use intern
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkettner committed Jul 24, 2015
1 parent d2b32e8 commit 5e6f7ae
Show file tree
Hide file tree
Showing 7 changed files with 820 additions and 807 deletions.
28 changes: 18 additions & 10 deletions gruntfile.js
Expand Up @@ -21,15 +21,22 @@
copy: {
plugins: {
files: [
{
expand: true,
cwd: "src/plugins/",
src: [ "**", "!gecko-picture/*" ],
dest: "dist/plugins/",
filter: "isFile"
}
{
expand: true,
cwd: "src/plugins/",
src: [ "**", "!gecko-picture/*" ],
dest: "dist/plugins/",
filter: "isFile"
}
],
},
}
},
intern: {
options: {
runType: "runner",
config: "tests/intern",
suites: [ "tests/tests" ]
}
},
concat: {

Expand Down Expand Up @@ -59,7 +66,6 @@
]
}
},

qunit: {
files: [ "tests/*.html" ]
},
Expand All @@ -84,6 +90,7 @@
},
release: {
options: {
additionalFiles: [ "bower.json" ],
commitMessage: "Picturefill <%= version %>",
tagMessage: "Picturefill <%= version %>",
afterRelease: [ "gh-pages" ]
Expand Down Expand Up @@ -121,10 +128,11 @@
grunt.loadNpmTasks("grunt-jscs-checker");
grunt.loadNpmTasks("grunt-gh-pages");
grunt.loadNpmTasks("grunt-release");
grunt.loadNpmTasks("intern");

// Default task.
grunt.registerTask("default", [ "jscs", "test", "clean", "concat", "copy", "uglify" ]);
grunt.registerTask("test", [ "jscs", "jshint", "qunit" ]);
grunt.registerTask("test", [ "jscs", "jshint", "intern" ]);
grunt.registerTask("publish", [ "gh-pages" ]);
};
})();
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -37,6 +37,7 @@
"grunt-gh-pages": "^0.10.0",
"grunt-insert": "~0.1.0",
"grunt-jscs-checker": "~0.4.3",
"grunt-release": "^0.12.0"
"grunt-release": "^0.12.0",
"intern": "^3.0.0-rc.3"
}
}
2 changes: 1 addition & 1 deletion src/picturefill.js
Expand Up @@ -1416,7 +1416,7 @@
module.exports = picturefill;
} else if ( typeof define === "function" && define.amd ) {
// AMD support
define( "picturefill", function() { return picturefill; } );
define( "picturefill", [], function() { return picturefill; } );
}

} )( window, document );
126 changes: 3 additions & 123 deletions tests/index.html
@@ -1,123 +1,3 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>picturefill main tests</title>
<link rel="stylesheet" href="resources/qunit-1.17.1.css" />
<script src="resources/qunit-1.17.1.js"></script>
<script src="resources/jquery-1.11.2.js"></script>
<script>
document.createElement('picture');
</script>
<script src="resources/modernizr.js"></script>
</head>
<body>

<script>
(function(){
var image = document.createElement( "img" );
window.imgGet = image.getAttribute;
window.imgSet = image.setAttribute;
})();
if(!window.picturefillCFG){
window.picturefillCFG = [];
}

window.picturefillCFG.push(['uT', true]);
</script>
<script src="../src/picturefill.js" data-cover></script>



<div id="qunit"></div>

<div id="qunit-fixture">

<!-- Functional tests -->
<picture>
<!-- First `source` in source order is selected -->
<audio>
<source srcset="../examples/images/small.jpg" />
<source srcset="../examples/images/extralarge.jpg" />
</audio>
<img class="first-match">
</picture>

<!-- dummy elements used as a mock pictures -->
<picture class="video-shim">
<video style="display: none;">
<source class="source-one"/>
<source class="source-two"/>
</video>
</picture>

<picture class="audio-shim">
<audio>
<source class="source-one"/>
<source class="source-two"/>
</audio>
</picture>

<img src="bar" class="prop-check"/>

<picture>
<img srcset="imgsrcset" class="ignored-source-check">
<video style="display: none;">
<source srcset="sourcesrcset"></source>
</video>
</picture>

<picture>
<!-- First `source` in source order is selected -->
<img class="match">
<audio>
<source srcset="baz"></source>
</audio>
<img class="match-second" src="baz">
</picture>

<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source type="foo" srcset="foo"/>
<!--[if IE 9]></video><![endif]-->

<img class="pending-check" src="test" />
</picture>

<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source srcset="foo" media="bar"/>
<!--[if IE 9]></video><![endif]-->
<img class="match-check" src="test" />
</picture>

<picture>
<video style="display: none;">
<source srcset="foo" media="bar"/>
</video>
<img class="no-match-check" src="" />
</picture>

<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source media="bar"/>
<!--[if IE 9]></video><![endif]-->
<img class="no-srcset-check" src="" />
</picture>

<div class="src-source-check">
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source src="" />
<!--[if IE 9]></video><![endif]-->
</picture>
</div>

</div>
<ul>
<li><a href="index-functional.html">functional tests</a></li>
<li><a href="index-mutation.html">mutation tests</a></li>
</ul>
<script src="tests.js" async=""></script>
</body>
</html>
<!doctype html>
<title>redirecting...</title>
<meta http-equiv="refresh" content="0; url=../node_modules/intern/client.html?config=tests/intern&reporters=Html&reporters=Console">
23 changes: 23 additions & 0 deletions tests/intern.js
@@ -0,0 +1,23 @@
define({
proxyPort: 9000,
proxyUrl: "http://localhost:9000/",
capabilities: {
"selenium-version": "2.45.0"
},
environments: [
//{ browserName: "safari"},
//{ browserName: "chrome"},
{ browserName: "firefox"},
//{ browserName: "internet explorer", version: "11"},
//{ browserName: "internet explorer", version: "10"},
//{ browserName: "internet explorer", version: "9"},
//{ browserName: "internet explorer", version: "8"},
//{ browserName: "safari", version: "6"},
//{ browserName: "safari", version: "7"}
],
maxConcurrency: 3,
suites: [ "intern/node_modules/dojo/has!host-browser?tests/tests" ],
functionalSuites: [],
// tunnel: "BrowserStackTunnel",
excludeInstrumentation: /^(?:tests|node_modules)\//
});
91 changes: 91 additions & 0 deletions tests/resources/fixtures.html
@@ -0,0 +1,91 @@
<!doctype html>
<html>
<head>
<title>picturefill main tests</title>
</head>
<body>
<div id="fixtures">

<!-- Functional tests -->
<picture>
<!-- First `source` in source order is selected -->
<audio>
<source srcset="../examples/images/small.jpg" />
<source srcset="../examples/images/extralarge.jpg" />
</audio>
<img class="first-match">
</picture>

<!-- dummy elements used as a mock pictures -->
<picture class="video-shim">
<video style="display: none;">
<source class="source-one"/>
<source class="source-two"/>
</video>
</picture>

<picture class="audio-shim">
<audio>
<source class="source-one"/>
<source class="source-two"/>
</audio>
</picture>

<img src="bar" class="prop-check"/>

<picture>
<img srcset="imgsrcset" class="ignored-source-check">
<video style="display: none;">
<source srcset="sourcesrcset"></source>
</video>
</picture>

<picture>
<!-- First `source` in source order is selected -->
<img class="match">
<audio>
<source srcset="baz"></source>
</audio>
<img class="match-second" src="baz">
</picture>

<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source type="foo" srcset="foo"/>
<!--[if IE 9]></video><![endif]-->

<img class="pending-check" src="test" />
</picture>

<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source srcset="foo" media="bar"/>
<!--[if IE 9]></video><![endif]-->
<img class="match-check" src="test" />
</picture>

<picture>
<video style="display: none;">
<source srcset="foo" media="bar"/>
</video>
<img class="no-match-check" src="" />
</picture>

<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source media="bar"/>
<!--[if IE 9]></video><![endif]-->
<img class="no-srcset-check" src="" />
</picture>

<div class="src-source-check">
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source src="" />
<!--[if IE 9]></video><![endif]-->
</picture>
</div>

</div>
</body>
</html>

0 comments on commit 5e6f7ae

Please sign in to comment.