Skip to content

Commit 626b801

Browse files
committed
[WIP]: Add simple tests for Android 2.3
Fixes gh-2505 Refs gh-2483
1 parent 5fe76c6 commit 626b801

File tree

4 files changed

+104
-4
lines changed

4 files changed

+104
-4
lines changed

Gruntfile.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ module.exports = function( grunt ) {
110110
},
111111
testswarm: {
112112
tests: [
113+
// A special module with basic tests, meant for
114+
// not fully supported environments like Android 2.3,
115+
// jsdom or PhantomJS. We run it everywhere, though,
116+
// to make sure tests are not broken.
117+
"basic",
118+
113119
"ajax",
114120
"animation",
115121
"attributes",

build/tasks/testswarm.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = function( grunt ) {
33
"use strict";
44

55
grunt.registerTask( "testswarm", function( commit, configFile, projectName, browserSets,
6-
timeout ) {
6+
timeout, testMode ) {
77
var jobName, config, tests,
88
testswarm = require( "testswarm" ),
99
runs = {},
@@ -28,9 +28,13 @@ module.exports = function( grunt ) {
2828
commit + "'>" + commit.substr( 0, 10 ) + "</a>";
2929
}
3030

31-
tests.forEach(function( test ) {
32-
runs[ test ] = config.testUrl + commit + "/test/index.html?module=" + test;
33-
});
31+
if ( testMode === "basic" ) {
32+
runs.basic = config.testUrl + commit + "/test/index.html?module=basic";
33+
} else {
34+
tests.forEach( function( test ) {
35+
runs[ test ] = config.testUrl + commit + "/test/index.html?module=" + test;
36+
} );
37+
}
3438

3539
testswarm.createClient({
3640
url: config.swarmUrl

test/data/testinit.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ this.loadTests = function() {
268268
// Get testSubproject from testrunner first
269269
require([ "data/testrunner.js" ], function() {
270270
var tests = [
271+
// A special module with basic tests, meant for
272+
// not fully supported environments like Android 2.3,
273+
// jsdom or PhantomJS. We run it everywhere, though,
274+
// to make sure tests are not broken.
275+
"unit/basic.js",
276+
271277
"unit/core.js",
272278
"unit/callbacks.js",
273279
"unit/deferred.js",

test/unit/basic.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
module( "basic", {
2+
teardown: moduleTeardown
3+
} );
4+
5+
if ( jQuery.css ) {
6+
test( "css", function() {
7+
expect( 18 );
8+
9+
var hiddendiv, disconnectedDiv, div, index,
10+
sizes = [ "10px", "20px" ];
11+
12+
hiddendiv = jQuery( "<div style='display:none;'><div style='height:20px;'></div></div>" ).appendTo( "#qunit-fixture" );
13+
14+
equal( hiddendiv.find( "div" ).css( "height" ), "20px", "Height on hidden div" );
15+
16+
disconnectedDiv = jQuery( "<div/>" );
17+
18+
disconnectedDiv.css( { "width": 4, "height": 4, "paddingLeft": 7 } );
19+
20+
equal( disconnectedDiv[ 0 ].style.height, "4px", "Make sure the height is being set correctly" );
21+
equal( disconnectedDiv.css( "width" ), "4px", "Width on disconnected node" );
22+
equal( disconnectedDiv.css( "height" ), "4px", "Height on disconnected node" );
23+
equal( disconnectedDiv.css( "paddingLeft" ), "7px", "Padding-left on disconnected node" );
24+
25+
disconnectedDiv.css( "width", 5 );
26+
27+
equal( disconnectedDiv[ 0 ].style.width, "5px", "Make sure the width is being set correctly" );
28+
equal( disconnectedDiv.css( "width" ), "5px", "Width on disconnected node" );
29+
equal( disconnectedDiv.css( "height" ), "4px", "Height on disconnected node" );
30+
31+
equal( jQuery( "<div style='display: none;'/>" ).css( "display" ), "none",
32+
"Styles on disconnected nodes" );
33+
34+
div = jQuery( "<div/>" );
35+
div.appendTo( "#qunit-fixture" );
36+
37+
div.css( { "width": 4, "height": 4, "paddingLeft": 7, "top": 5 } );
38+
39+
div.css( { width: "+=9" } );
40+
equal( div.css( "width" ), "13px", "'+=9' on width (hash)" );
41+
42+
div.css( "width", "-=9px" );
43+
equal( div.css( "width" ), "4px", "'-=9px' on width (params)" );
44+
45+
div.css( { "paddingLeft": "+=4px" } );
46+
equal( div.css( "paddingLeft" ), "11px", "'+=4' on paddingLeft (hash)" );
47+
48+
div.css( "padding-left", "-=4" );
49+
equal( div.css( "paddingLeft" ), "7px", "'-=4' on padding-left (params)" );
50+
51+
div.css( "paddingLeft", "" );
52+
equal( div.css( "padding-left" ), "0px", "Zeroing the value" );
53+
54+
jQuery( "<div id='cssFunctionTest'><div class='cssFunction'></div>" +
55+
"<div class='cssFunction'></div></div>" )
56+
.appendTo( "#qunit-fixture" );
57+
58+
index = 0;
59+
60+
jQuery( "#cssFunctionTest div" ).css( "font-size", function() {
61+
var size = sizes[ index ];
62+
index++;
63+
return size;
64+
} );
65+
66+
index = 0;
67+
68+
jQuery( "#cssFunctionTest div" ).each( function() {
69+
var computedSize = jQuery( this ).css( "font-size" ),
70+
expectedSize = sizes[ index ];
71+
equal( computedSize, expectedSize,
72+
"css(String, Function): Div #" + index + " should be " + expectedSize );
73+
index++;
74+
} );
75+
76+
div = jQuery( "<div>" ).hide();
77+
equal( div.css( "display" ), "none", "Detached div hidden" );
78+
div.appendTo( "#qunit-fixture" ).show();
79+
equal( div.css( "display" ), "block", "Initially-detached div after show()" );
80+
} );
81+
}
82+
83+
84+
// TODO write tests for other modules

0 commit comments

Comments
 (0)