-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test framework (using karma and jasmine, launched via grunt, fron…
…tend via `npm test`) and a basic test.
- Loading branch information
Tom Clift
committed
May 27, 2014
1 parent
84f0939
commit 6791a1e
Showing
7 changed files
with
120 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,3 +163,4 @@ pip-log.txt | |
.DS_Store | ||
|
||
bower_components/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = function(grunt) { | ||
grunt.config.init({ | ||
karma: { | ||
options: { | ||
browsers: [ 'Chrome', 'Firefox', 'Safari', 'Opera', 'IE' ], | ||
frameworks: [ 'jasmine' ], | ||
reportSlowerThan: 500, | ||
singleRun: true | ||
}, | ||
unit: { | ||
files: [ | ||
{ pattern: 'bower_components/jquery/dist/jquery.min.js' }, | ||
{ pattern: 'bower_components/jasmine-jquery/lib/jasmine-jquery.js' }, | ||
{ pattern: 'jquery.are-you-sure.js' }, | ||
{ pattern: 'spec/javascripts/*.js' }, | ||
{ pattern: 'spec/javascripts/fixtures/**/*.html', included: false } | ||
] | ||
} | ||
} | ||
}); | ||
|
||
grunt.registerTask('test', 'Run tests.', [ 'karma' ]); | ||
grunt.registerTask('default', [ 'test' ]); | ||
|
||
grunt.loadNpmTasks('grunt-karma'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,8 @@ | |
], | ||
"dependencies": { | ||
"jquery": ">=1.4.2" | ||
}, | ||
"devDependencies": { | ||
"jasmine-jquery": "~2.0.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "jquery.AreYouSure", | ||
"description": "A light-weight jQuery \"dirty forms\" Plugin - it monitors HTML forms and alerts users to unsaved changes if they attempt to close the browser or navigate away from the page. (Are you sure?)", | ||
"homepage": "https://github.com/codedance/jquery.AreYouSure", | ||
"author": "Chris Dance <[email protected]> (https://github.com/codedance)", | ||
"contributors": [ | ||
"Tom Clift <[email protected]> (https://github.com/tclift)", | ||
"Jon Egerton <[email protected]> (http://www.jonegerton.com/)", | ||
"Scadoodles (https://github.com/Scadoodles)", | ||
"Albin Sunnanbo (https://github.com/albinsunnanbo)", | ||
"Marc Sutton <[email protected]> (http://www.codev.co.uk)" | ||
], | ||
"version": "1.7.0", | ||
"license": "MIT/GPLv2", | ||
"keywords": [ "dirty", "form", "onbeforeunload", "save", "check" ], | ||
"main": "jquery.are-you-sure.js", | ||
"engines": { | ||
"node": ">=0.8.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/codedance/jquery.AreYouSure" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/codedance/jquery.AreYouSure/issues" | ||
}, | ||
"dependencies": { | ||
"jquery": ">=1.4.2" | ||
}, | ||
"devDependencies": { | ||
"bower": "^1.3.1", | ||
"grunt": "^0.4.5", | ||
"grunt-cli": "^0.1.13", | ||
"grunt-karma": "^0.8.3", | ||
"karma-chrome-launcher": "^0.1.4", | ||
"karma-jasmine": "^0.2.2", | ||
"karma-ie-launcher": "^0.1.5", | ||
"karma-opera-launcher": "^0.1.0", | ||
"karma-firefox-launcher": "^0.1.3", | ||
"karma-safari-launcher": "^0.1.1" | ||
}, | ||
"scripts": { | ||
"postinstall": "$(npm bin)/bower install && npm prune && $(npm bin)/bower prune", | ||
"test": "$(npm bin)/grunt test" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<form> | ||
<input type="text" name="a"> | ||
<input type="submit"> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
// Karma adds 'base/' to the default path | ||
jasmine.getFixtures().fixturesPath = 'base/spec/javascripts/fixtures'; | ||
|
||
describe("A form's", function() { | ||
var $form = undefined; | ||
|
||
describe('text input', function() { | ||
var $textInput = undefined; | ||
|
||
beforeEach(function() { | ||
loadFixtures('input-text.html'); | ||
$form = $('form'); | ||
$textInput = $('input[type=text]'); | ||
$form.areYouSure(); | ||
}); | ||
|
||
it('should cause dirtyness after its value changes', function(done) { | ||
expect($form.hasClass('dirty')).toBe(false); | ||
$textInput.val('new').change(); | ||
setTimeout(function() { | ||
expect($form.hasClass('dirty')).toBe(true); | ||
done(); | ||
}, 0); | ||
}); | ||
}); | ||
}); |