Skip to content

Commit b576266

Browse files
author
Kevin Morris
committed
test: Adds remaining test files
1 parent b6df1cf commit b576266

File tree

9 files changed

+71
-23
lines changed

9 files changed

+71
-23
lines changed

Gruntfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = function(grunt) {
1414

1515
mocha: {
1616
all: {
17-
src: ['test/**/*.html'],
17+
src: ['test/*.html'],
1818
},
1919
options: {
2020
run: true

test/ajax/doc-with-scripts.html

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<div>
2+
3+
Lorem ipsum dolor sit amet
4+
5+
<script type="text/javascript">
6+
// set global var
7+
var unitTestVariable1 = true;
8+
</script>
9+
10+
Lorem ipsum dolor sit amet
11+
12+
<script type="text/javascript">
13+
// set another global var
14+
var unitTestVariable2 = true;
15+
</script>
16+
17+
<script type="text/javascript">
18+
// set global var
19+
if (typeof scriptCount == 'undefined')
20+
var scriptCount = 1;
21+
else
22+
scriptCount++;
23+
</script>
24+
25+
Lorem ipsum dolor sit amet
26+
27+
</div>

test/ajax/json.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "name": "jquery-test" }

test/ajax/json.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "name": "jquery-test" }

test/ajax/script.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
formScriptTest = function() {
2+
// no-op
3+
}

test/ajax/test.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<root>
2+
<test></test>
3+
<test></test>
4+
<test></test>
5+
</root>

test/ajax/text.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Lorem ipsum dolor sit amet
2+
consectetuer adipiscing elit
3+
Sed lorem leo
4+
lorem leo consectetuer adipiscing elit
5+
Sed lorem leo
6+
rhoncus sit amet
7+
elementum at
8+
bibendum at, eros
9+
Cras at mi et tortor egestas vestibulum
10+
sed Cras at mi vestibulum
11+
Phasellus sed felis sit amet
12+
orci dapibus semper.

test/test.html

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<!-- Test HTML -->
1515
<div id="main" style="display: none;">
1616
<!-- form1 -->
17-
<form id="form1" action="text.php" method="get">
17+
<form id="form1" action="ajax/text.html" method="get">
1818
<div>
1919
<input type="hidden" name="Hidden" value="hiddenValue">
2020
<input name="Name" type="text" value="MyName1">
@@ -66,7 +66,7 @@
6666
</form>
6767

6868
<!-- form2 -->
69-
<form id="form2" action="text.php" method="get">
69+
<form id="form2" action="ajax/text.html" method="get">
7070
<div>
7171
<input name="a" type="text">
7272
<textarea name="b" rows="1" cols="1"></textarea>
@@ -79,34 +79,34 @@
7979
</form>
8080

8181
<!-- form3 -->
82-
<form id="form3" action="text.php" method="post">
82+
<form id="form3" action="ajax/text.html" method="post">
8383
<div>
8484
<input name="a" type="text">
8585
</div>
8686
</form>
8787

8888
<!-- form4 -->
89-
<form id="form4" action="text.php" method="get">
89+
<form id="form4" action="ajax/text.html" method="get">
9090
<div>
9191
<input name="a" type="text">
9292
<input type="submit" id="submitForm4">
9393
<input type="submit" id="submitForm4withName" name="form4inputName">
94-
<input type="image" id="form4imageSubmit" name="myImage" src="submit.gif">
94+
<input type="image" id="form4imageSubmit" name="myImage" src="img/submit.gif">
9595
</div>
9696
</form>
9797

9898
<!-- form5 -->
99-
<form id="form5" action="text.php?test=form" method="get">
99+
<form id="form5" action="ajax/text.html?test=form" method="get">
100100
<div>
101101
<input name="a" type="text">
102102
<input type="submit">
103103
<input type="submit" name="form5inputName">
104-
<input type="image" id="form5imageSubmit" name="myImage" src="submit.gif">
104+
<input type="image" id="form5imageSubmit" name="myImage" src="img/submit.gif">
105105
</div>
106106
</form>
107107

108108
<!-- form6, 'option' testing -->
109-
<form id="form6" action="text.php" method="get">
109+
<form id="form6" action="ajax/text.html" method="get">
110110
<div>
111111
<select name="A">
112112
<option value="" selected="selected">EMPTY_STRING</option> <!-- TEST A: value === empty string -->
@@ -122,20 +122,20 @@
122122
</form>
123123

124124
<!-- form7, 'enctype' testing -->
125-
<form id="form7" action="text.php" method="post" enctype="text/css">
125+
<form id="form7" action="ajax/text.html" method="post" enctype="text/css">
126126
<div>
127127
<textarea name="doc">body { padding: 0}</textarea>
128128
</div>
129129
</form>
130130

131-
<form id="form8" action="text.php" method="post">
131+
<form id="form8" action="ajax/text.html" method="post">
132132
<div>
133133
<textarea name="ta">blah</textarea>
134134
<input type="submit" id="submitForm8">
135135
</div>
136136
</form>
137137

138-
<form id="form9" action="text.php" method="post">
138+
<form id="form9" action="ajax/text.html" method="post">
139139
<div>
140140
<textarea name="ta">blah</textarea>
141141
<input type="submit" id="submitForm9">
@@ -160,7 +160,7 @@
160160
<input type="submit" value="button">
161161
</div>
162162

163-
<form style="display:none" id="fieldTest" action="text.php" method="post">
163+
<form style="display:none" id="fieldTest" action="ajax/text.html" method="post">
164164
<div>
165165
<select name="A">
166166
<option value="1" selected="selected">ONE</option>

test/test.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global chai */
1+
/* global chai, scriptCount */
22

33
'use strict';
44

@@ -39,7 +39,7 @@ describe('form', function() {
3939

4040
it('"action" and "method" form attributes', function() {
4141
var f = $('#form1');
42-
assert.strictEqual(f.attr('action'), 'text.php', 'form "action"');
42+
assert.strictEqual(f.attr('action'), 'ajax/text.html', 'form "action"');
4343
assert.strictEqual(f.attr('method'), 'get', 'form "method"');
4444
});
4545

@@ -212,7 +212,6 @@ describe('form', function() {
212212
assert.ok(!el.checked, 'success: ' + el.checked);
213213
});
214214

215-
216215
// test clearForm
217216
it('clearForm (radio)', function() {
218217
var el = $('#form1 input:radio:checked')[0];
@@ -283,7 +282,7 @@ describe('form', function() {
283282

284283
var opts = {
285284
target: '#targetDiv',
286-
url: 'doc-with-scripts.html?' + new Date().getTime(),
285+
url: 'ajax/doc-with-scripts.html?' + new Date().getTime(),
287286
success: function(responseText) { // post-callback
288287
assert.ok(true, 'success-callback');
289288
assert.ok($('#targetDiv').text().match('Lorem ipsum'), 'targetDiv updated');
@@ -367,7 +366,7 @@ describe('form', function() {
367366
// stop();
368367

369368
var opts = {
370-
url: 'json.json',
369+
url: 'ajax/json.json',
371370
dataType: 'json',
372371
success: function(data, statusText) { // post-submit callback
373372
// assert that the json data was evaluated
@@ -387,7 +386,7 @@ describe('form', function() {
387386
// stop();
388387

389388
var opts = {
390-
url: 'script.txt?' + new Date().getTime(), // don't let ie cache it
389+
url: 'ajax/script.txt?' + new Date().getTime(), // don't let ie cache it
391390
dataType: 'script',
392391
success: function(responseText, statusText) { // post-submit callback
393392
assert.ok(typeof formScriptTest == 'function', 'script evaluated');
@@ -405,7 +404,7 @@ describe('form', function() {
405404
// stop();
406405

407406
var opts = {
408-
url: 'test.xml',
407+
url: 'ajax/test.xml',
409408
dataType: 'xml',
410409
success: function(responseXML, statusText) { // post-submit callback
411410
assert.ok(typeof responseXML == 'object', 'data type xml');
@@ -471,7 +470,7 @@ describe('form', function() {
471470
},
472471
// url and method must be provided for a pseudo form since they can
473472
// not be extracted from the markup
474-
url: 'text.php',
473+
url: 'ajax/text.html',
475474
type: 'post'
476475
};
477476

@@ -490,7 +489,7 @@ describe('form', function() {
490489
assert.ok(data.name == 'jquery-test', 'evaled response');
491490
// start();
492491
},
493-
url: 'json.txt'
492+
url: 'ajax/json.txt'
494493
};
495494

496495
// expect(2);
@@ -617,7 +616,7 @@ describe('form', function() {
617616
// stop();
618617

619618
var opts = {
620-
url: 'bogus.php',
619+
url: 'ajax/404.html',
621620
error: function() {
622621
assert.ok(true, 'error-callback');
623622
// start();

0 commit comments

Comments
 (0)