Skip to content

Commit

Permalink
test: Adds remaining test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Morris committed Mar 9, 2017
1 parent b6df1cf commit b576266
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function(grunt) {

mocha: {
all: {
src: ['test/**/*.html'],
src: ['test/*.html'],
},
options: {
run: true
Expand Down
27 changes: 27 additions & 0 deletions test/ajax/doc-with-scripts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div>

Lorem ipsum dolor sit amet

<script type="text/javascript">
// set global var
var unitTestVariable1 = true;
</script>

Lorem ipsum dolor sit amet

<script type="text/javascript">
// set another global var
var unitTestVariable2 = true;
</script>

<script type="text/javascript">
// set global var
if (typeof scriptCount == 'undefined')
var scriptCount = 1;
else
scriptCount++;
</script>

Lorem ipsum dolor sit amet

</div>
1 change: 1 addition & 0 deletions test/ajax/json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "name": "jquery-test" }
1 change: 1 addition & 0 deletions test/ajax/json.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "name": "jquery-test" }
3 changes: 3 additions & 0 deletions test/ajax/script.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
formScriptTest = function() {
// no-op
}
5 changes: 5 additions & 0 deletions test/ajax/test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<root>
<test></test>
<test></test>
<test></test>
</root>
12 changes: 12 additions & 0 deletions test/ajax/text.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Lorem ipsum dolor sit amet
consectetuer adipiscing elit
Sed lorem leo
lorem leo consectetuer adipiscing elit
Sed lorem leo
rhoncus sit amet
elementum at
bibendum at, eros
Cras at mi et tortor egestas vestibulum
sed Cras at mi vestibulum
Phasellus sed felis sit amet
orci dapibus semper.
24 changes: 12 additions & 12 deletions test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- Test HTML -->
<div id="main" style="display: none;">
<!-- form1 -->
<form id="form1" action="text.php" method="get">
<form id="form1" action="ajax/text.html" method="get">
<div>
<input type="hidden" name="Hidden" value="hiddenValue">
<input name="Name" type="text" value="MyName1">
Expand Down Expand Up @@ -66,7 +66,7 @@
</form>

<!-- form2 -->
<form id="form2" action="text.php" method="get">
<form id="form2" action="ajax/text.html" method="get">
<div>
<input name="a" type="text">
<textarea name="b" rows="1" cols="1"></textarea>
Expand All @@ -79,34 +79,34 @@
</form>

<!-- form3 -->
<form id="form3" action="text.php" method="post">
<form id="form3" action="ajax/text.html" method="post">
<div>
<input name="a" type="text">
</div>
</form>

<!-- form4 -->
<form id="form4" action="text.php" method="get">
<form id="form4" action="ajax/text.html" method="get">
<div>
<input name="a" type="text">
<input type="submit" id="submitForm4">
<input type="submit" id="submitForm4withName" name="form4inputName">
<input type="image" id="form4imageSubmit" name="myImage" src="submit.gif">
<input type="image" id="form4imageSubmit" name="myImage" src="img/submit.gif">
</div>
</form>

<!-- form5 -->
<form id="form5" action="text.php?test=form" method="get">
<form id="form5" action="ajax/text.html?test=form" method="get">
<div>
<input name="a" type="text">
<input type="submit">
<input type="submit" name="form5inputName">
<input type="image" id="form5imageSubmit" name="myImage" src="submit.gif">
<input type="image" id="form5imageSubmit" name="myImage" src="img/submit.gif">
</div>
</form>

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

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

<form id="form8" action="text.php" method="post">
<form id="form8" action="ajax/text.html" method="post">
<div>
<textarea name="ta">blah</textarea>
<input type="submit" id="submitForm8">
</div>
</form>

<form id="form9" action="text.php" method="post">
<form id="form9" action="ajax/text.html" method="post">
<div>
<textarea name="ta">blah</textarea>
<input type="submit" id="submitForm9">
Expand All @@ -160,7 +160,7 @@
<input type="submit" value="button">
</div>

<form style="display:none" id="fieldTest" action="text.php" method="post">
<form style="display:none" id="fieldTest" action="ajax/text.html" method="post">
<div>
<select name="A">
<option value="1" selected="selected">ONE</option>
Expand Down
19 changes: 9 additions & 10 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global chai */
/* global chai, scriptCount */

'use strict';

Expand Down Expand Up @@ -39,7 +39,7 @@ describe('form', function() {

it('"action" and "method" form attributes', function() {
var f = $('#form1');
assert.strictEqual(f.attr('action'), 'text.php', 'form "action"');
assert.strictEqual(f.attr('action'), 'ajax/text.html', 'form "action"');
assert.strictEqual(f.attr('method'), 'get', 'form "method"');
});

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


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

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

var opts = {
url: 'json.json',
url: 'ajax/json.json',
dataType: 'json',
success: function(data, statusText) { // post-submit callback
// assert that the json data was evaluated
Expand All @@ -387,7 +386,7 @@ describe('form', function() {
// stop();

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

var opts = {
url: 'test.xml',
url: 'ajax/test.xml',
dataType: 'xml',
success: function(responseXML, statusText) { // post-submit callback
assert.ok(typeof responseXML == 'object', 'data type xml');
Expand Down Expand Up @@ -471,7 +470,7 @@ describe('form', function() {
},
// url and method must be provided for a pseudo form since they can
// not be extracted from the markup
url: 'text.php',
url: 'ajax/text.html',
type: 'post'
};

Expand All @@ -490,7 +489,7 @@ describe('form', function() {
assert.ok(data.name == 'jquery-test', 'evaled response');
// start();
},
url: 'json.txt'
url: 'ajax/json.txt'
};

// expect(2);
Expand Down Expand Up @@ -617,7 +616,7 @@ describe('form', function() {
// stop();

var opts = {
url: 'bogus.php',
url: 'ajax/404.html',
error: function() {
assert.ok(true, 'error-callback');
// start();
Expand Down

0 comments on commit b576266

Please sign in to comment.