Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 46d1616

Browse files
committed
Tests: Add no-bootstrap folder with events files
- Add dir to grunt task also
1 parent 894e326 commit 46d1616

File tree

4 files changed

+94
-20
lines changed

4 files changed

+94
-20
lines changed

build/tasks/options/qunit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ return {
2424
options: {
2525
urls: ( function() {
2626
var allSuites, patterns, paths,
27-
testDirs = [ "unit", "integration", "css" ],
27+
testDirs = [ "unit", "integration", "css", "no-bootstrap" ],
2828
suites = ( grunt.option( "suites" ) || process.env.SUITES || "" )
2929
.split( "," ),
3030
types = ( grunt.option( "types" ) || process.env.TYPES || "" )

tests/no-bootstrap/event/event.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
( function( QUnit, $ ) {
2+
3+
var libName = "jquery.mobile.events.js",
4+
components = [ "events/touch.js", "events/throttledresize.js", "events/scroll.js",
5+
"events/orientationchange.js" ],
6+
absFn = Math.abs,
7+
originalEventFn = $.Event.prototype.originalEvent,
8+
preventDefaultFn = $.Event.prototype.preventDefault,
9+
events = ( "touchstart touchmove touchend tap taphold " +
10+
"swipe swipeleft swiperight scrollstart scrollstop orientationchange" ).split( " " );
11+
12+
QUnit.module( libName, {
13+
setup: function() {
14+
15+
// Ensure bindings are removed
16+
$.each( events.concat( "vmouseup vmousedown".split( " " ) ), function( i, name ) {
17+
$( "#qunit-fixture" ).unbind();
18+
} );
19+
20+
// Make sure the event objects respond to touches to simulate
21+
// the collections existence in non touch enabled test browsers
22+
$.Event.prototype.touches = [ { pageX: 1, pageY: 1 } ];
23+
24+
$( "body" ).unbind( "throttledresize" );
25+
},
26+
teardown: function() {
27+
28+
// NOTE unmock
29+
Math.abs = absFn;
30+
$.Event.prototype.originalEvent = originalEventFn;
31+
$.Event.prototype.preventDefault = preventDefaultFn;
32+
}
33+
} );
34+
35+
$.testHelper.excludeFileProtocol( function() {
36+
QUnit.test( "new events defined on the jquery object", function( assert ) {
37+
$.each( events, function( i, name ) {
38+
delete $.fn[ name ];
39+
assert.deepEqual( $.fn[ name ], undefined, "After deleting it, $.fn[ '" + name + "' ] is indeed undefined" );
40+
} );
41+
42+
$.each( components, function( index, value ) {
43+
$.testHelper.reloadModule( value );
44+
} );
45+
46+
$.each( events, function( i, name ) {
47+
assert.ok( $.fn[ name ] !== undefined, name + " should NOT be undefined" );
48+
} );
49+
} );
50+
} );
51+
52+
} )( QUnit, jQuery);

tests/no-bootstrap/event/index.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>jQuery Mobile Event Test Suite</title>
7+
8+
<script src="../../../js/jquery.tag.inserter.js"></script>
9+
<script src="../../jquery.setNameSpace.js"></script>
10+
<script src="../../../external/qunit/qunit.js"></script>
11+
<script src="../../../tests/jquery.testHelper.js"></script>
12+
<script type="text/javascript">
13+
$.testHelper.setPushState();
14+
</script>
15+
16+
<script src="../../../js/ns.js"></script>
17+
<script src="../../../js/support/touch.js"></script>
18+
<script src="../../../js/events.js"></script>
19+
<script src="../../../js/vmouse.js"></script>
20+
<script src="../../../js/events/touch.js"></script>
21+
<script src="../../../js/events/scroll.js"></script>
22+
<script src="../../../js/events/throttledresize.js"></script>
23+
<script src="../../../js/events/orientationchange.js"></script>
24+
25+
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/>
26+
<link rel="stylesheet" href="../../jqm-tests.css"/>
27+
28+
<script src="event.js"></script>
29+
</head>
30+
<body>
31+
32+
<div id="qunit"></div>
33+
34+
<div id="qunit-fixture"></div>
35+
36+
<div id="foo" data-nstest-role="page">
37+
<a href="#bar" data-nstest-transition="flip"></a>
38+
</div>
39+
40+
</body>
41+
</html>

tests/unit/event/event_core.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,6 @@ QUnit.module( libName, {
3535
}
3636
} );
3737

38-
// This test doesn't fit well with requirements of bootstrap
39-
40-
// $.testHelper.excludeFileProtocol( function() {
41-
// QUnit.test( "new events defined on the jquery object", function( assert ) {
42-
// $.each( events, function( i, name ) {
43-
// delete $.fn[ name ];
44-
// assert.deepEqual( $.fn[ name ], undefined, "After deleting it, $.fn[ '" + name + "' ] is indeed undefined" );
45-
// } );
46-
47-
// $.each( components, function( index, value ) {
48-
// $.testHelper.reloadModule( value );
49-
// } );
50-
51-
// $.each( events, function( i, name ) {
52-
// assert.ok( $.fn[ name ] !== undefined, name + " should NOT be undefined" );
53-
// } );
54-
// } );
55-
// } );
56-
5738
QUnit.asyncTest( "defined event functions bind a closure when passed", function( assert ) {
5839
assert.expect( 1 );
5940

0 commit comments

Comments
 (0)