Click here to load reader
Upload
miguel-parramon
View
2.416
Download
1
Embed Size (px)
Citation preview
jQuery Plugins & JasmineA lightning quick example
@mparramon
What?With
· some useful js code
Create
· a full-fledged jQuery
plugin
· with unit testing
In 5 minutes!
File inputs in some browsers:
The problem
let's fix it!
· add styling
· custom button
· initial value
Based on quirksmode.org/dom/inputfile.html
jQuery plugin
http://docs.jquery.com/Plugins/Authoring
Basic Framework
Defaults and options
Mantaining chainability
Unit testing with Jasmine
http://pivotal.github.com/jasmine/
Initial setupModify SpecRunner.html:
DSL
jasmine-jquery2 extensions for Jasmine:
· an HTML fixtures API· a set of jQuery custom matchers
https://github.com/velesin/jasmine-jquery
Fixtures
Expectations
Our final codejquery-enhancedfileinput
↳ lib
↳ jasmine-1.3.0
spec
↳ jquery-enhancedfileinput_spec.js
↳ jasmine-jquery-1.3.1.js
src
↳ jquery-enhancedfileinput.js
↳ demo.html
↳ README.md
↳ SpecRunner.html
No time!
@mparramon
github.com/mparramont
Questions?