mirror of https://github.com/twbs/ratchet.git
XhmikosR
9 years ago
9 changed files with 213 additions and 1 deletions
@ -0,0 +1,5 @@ |
|||||||
|
{ |
||||||
|
"devel" : true, |
||||||
|
"es3" : false, |
||||||
|
"jasmine" : true |
||||||
|
} |
@ -0,0 +1,69 @@ |
|||||||
|
<!doctype html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<meta charset="utf-8"> |
||||||
|
<title>Jasmine Spec Runner</title> |
||||||
|
<link rel="shortcut icon" type="image/png" href=".grunt/grunt-contrib-jasmine/jasmine_favicon.png"> |
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../.grunt/grunt-contrib-jasmine/jasmine.css"> |
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../dist/ratchet.min.css"> |
||||||
|
|
||||||
|
|
||||||
|
</head> |
||||||
|
<body> |
||||||
|
|
||||||
|
|
||||||
|
<script src="../../.grunt/grunt-contrib-jasmine/es5-shim.js"></script> |
||||||
|
|
||||||
|
<script src="../../.grunt/grunt-contrib-jasmine/jasmine.js"></script> |
||||||
|
|
||||||
|
<script src="../../.grunt/grunt-contrib-jasmine/jasmine-html.js"></script> |
||||||
|
|
||||||
|
<script src="../../.grunt/grunt-contrib-jasmine/json2.js"></script> |
||||||
|
|
||||||
|
<script src="../../.grunt/grunt-contrib-jasmine/boot.js"></script> |
||||||
|
|
||||||
|
<script src="../../docs/assets/js/fingerblast.js"></script> |
||||||
|
|
||||||
|
<script src="../common.js"></script> |
||||||
|
|
||||||
|
<script src="../modals.js"></script> |
||||||
|
|
||||||
|
<script src="../popovers.js"></script> |
||||||
|
|
||||||
|
<script src="../push.js"></script> |
||||||
|
|
||||||
|
<script src="../segmented-controllers.js"></script> |
||||||
|
|
||||||
|
<script src="../sliders.js"></script> |
||||||
|
|
||||||
|
<script src="../toggles.js"></script> |
||||||
|
|
||||||
|
<script src="vendor/touchfaker.min.js"></script> |
||||||
|
|
||||||
|
<script src="../common.js"></script> |
||||||
|
|
||||||
|
<script src="../modals.js"></script> |
||||||
|
|
||||||
|
<script src="../popovers.js"></script> |
||||||
|
|
||||||
|
<script src="../push.js"></script> |
||||||
|
|
||||||
|
<script src="../segmented-controllers.js"></script> |
||||||
|
|
||||||
|
<script src="../sliders.js"></script> |
||||||
|
|
||||||
|
<script src="../toggles.js"></script> |
||||||
|
|
||||||
|
<script src="commonSpec.js"></script> |
||||||
|
|
||||||
|
<script src="modalsSpec.js"></script> |
||||||
|
|
||||||
|
<script src="sliderSpec.js"></script> |
||||||
|
|
||||||
|
<script src="../../.grunt/grunt-contrib-jasmine/reporter.js"></script> |
||||||
|
|
||||||
|
|
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,20 @@ |
|||||||
|
describe('Common', function () { |
||||||
|
it('RATCHET namespace is defined', function () { |
||||||
|
expect(typeof RATCHET !== 'undefined').toBe(true); |
||||||
|
}); |
||||||
|
|
||||||
|
it('window.CustomEvent exists', function () { |
||||||
|
expect(typeof window.CustomEvent !== 'undefined').toBe(true); |
||||||
|
}); |
||||||
|
|
||||||
|
it('RATCHET.getBrowserCapabilities returns an object', function () { |
||||||
|
var result = RATCHET.getBrowserCapabilities; |
||||||
|
expect(typeof result === 'object').toBe(true); |
||||||
|
}); |
||||||
|
|
||||||
|
it('RATCHET.getTransitionEnd returns string', function () { |
||||||
|
var result = RATCHET.getTransitionEnd; |
||||||
|
expect(typeof result === 'string').toBe(true); |
||||||
|
expect(result.length > 0).toBe(true); |
||||||
|
}); |
||||||
|
}); |
@ -0,0 +1,52 @@ |
|||||||
|
describe('Modals', function () { |
||||||
|
beforeEach(function () { |
||||||
|
var templateModal = [ |
||||||
|
'<a id="linkOpenModal" href="#myModal" class="btn">Open modal</a>', |
||||||
|
'<div id="myModal" class="modal">', |
||||||
|
'<header class="bar bar-nav">', |
||||||
|
'<a id="linkCloseModal" class="icon icon-close pull-right" href="#myModal"></a>', |
||||||
|
'<h1 class="title">Modal</h1>', |
||||||
|
'</header>', |
||||||
|
'<div class="content">', |
||||||
|
'<p class="content-padded">The contents of my modal go here.</p>', |
||||||
|
'</div>', |
||||||
|
'</div>' |
||||||
|
].join(''); |
||||||
|
document.body.innerHTML += templateModal; |
||||||
|
}); |
||||||
|
|
||||||
|
afterEach(function () { |
||||||
|
var linkModal = document.getElementById('linkOpenModal'); |
||||||
|
var modal = document.getElementById('myModal'); |
||||||
|
linkModal.parentNode.removeChild(linkModal); |
||||||
|
modal.parentNode.removeChild(modal); |
||||||
|
}); |
||||||
|
|
||||||
|
it('Modal should fire modalOpen event', function (done) { |
||||||
|
window.addEventListener('modalOpen', function () { |
||||||
|
expect(true).toBe(true); |
||||||
|
done(); |
||||||
|
}); |
||||||
|
var link = document.getElementById('linkOpenModal'); |
||||||
|
var eventTouchEnd = new CustomEvent('touchend', { |
||||||
|
bubbles: true, |
||||||
|
cancelable: true |
||||||
|
}); |
||||||
|
link.dispatchEvent(eventTouchEnd); |
||||||
|
}); |
||||||
|
|
||||||
|
it('Modal should fire modalClose event', function (done) { |
||||||
|
var link = document.getElementById('linkOpenModal'); |
||||||
|
var eventTouchEnd = new CustomEvent('touchend', { |
||||||
|
bubbles: true, |
||||||
|
cancelable: true |
||||||
|
}); |
||||||
|
window.addEventListener('modalClose', function () { |
||||||
|
expect(true).toBe(true); |
||||||
|
done(); |
||||||
|
}); |
||||||
|
link.dispatchEvent(eventTouchEnd); |
||||||
|
var closeLink = document.getElementById('linkCloseModal'); |
||||||
|
closeLink.dispatchEvent(eventTouchEnd); |
||||||
|
}); |
||||||
|
}); |
@ -0,0 +1,32 @@ |
|||||||
|
describe('Slider', function () { |
||||||
|
var slider = null; |
||||||
|
beforeEach(function () { |
||||||
|
var templateSlider = [ |
||||||
|
'<div class="slider" id="mySlider">', |
||||||
|
'<div id="mySlider" class="slide-group">', |
||||||
|
'<div id="firstSlide" class="slide">', |
||||||
|
'<img src="http://goratchet.com/assets/img/slide-2.jpg">', |
||||||
|
'</div>', |
||||||
|
'<div class="slide">', |
||||||
|
'<img src="http://goratchet.com/assets/img/slide-3.jpg">', |
||||||
|
'</div>', |
||||||
|
'</div>', |
||||||
|
'</div>' |
||||||
|
].join(''); |
||||||
|
document.body.innerHTML += templateSlider; |
||||||
|
slider = document.getElementById('mySlider'); |
||||||
|
}); |
||||||
|
|
||||||
|
afterEach(function () { |
||||||
|
slider.parentNode.removeChild(slider); |
||||||
|
slider = null; |
||||||
|
}); |
||||||
|
|
||||||
|
it('Slider should fire slide event', function (done) { |
||||||
|
slider.addEventListener('slide', function () { |
||||||
|
expect(true).toBe(true); |
||||||
|
done(); |
||||||
|
}); |
||||||
|
TouchFaker.fakeEvent('touchstart', '#firstSlide'); |
||||||
|
}); |
||||||
|
}); |
@ -0,0 +1,6 @@ |
|||||||
|
/*! |
||||||
|
* TouchFaker - v1.1.0 - 2015-05-21 |
||||||
|
* https://github.com/Johann-S/TouchFaker
|
||||||
|
* Copyright (c) 2015 Johann SERVOIRE; Licensed MIT |
||||||
|
*/ |
||||||
|
!function(){"use strict";function a(a,b,c,d,e){d=d||0,e=e||0,this.identifier=b,this.target=a,this.clientX=c.clientX+d||0,this.clientY=c.clientY+e||0,this.screenX=c.screenX+d||0,this.screenY=c.screenY+e||0,this.pageX=c.pageX+d||0,this.pageY=c.pageY+e||0}function b(){var a=[];return a.item=function(a){return this[a]||null},a.identifiedTouch=function(a){return this[a+1]||null},a}function c(){for(var a=[window,document.documentElement],b=["ontouchstart","ontouchmove","ontouchcancel","ontouchend"],c=0;c<a.length;c++)for(var d=0;d<b.length;d++)a[c]&&void 0===a[c][b[d]]&&(a[c][b[d]]=null)}function d(){return"ontouchstart"in window||window.Modernizr&&window.Modernizr.touch||(navigator.msMaxTouchPoints||navigator.maxTouchPoints)>2}function e(a,b,c){var d=document.createEvent("Event");d.initEvent(a,!0,!0);var e="undefined"!=typeof c?g(c):f(b);d.touches=i(e,a,b),d.targetTouches=i(e,a,b),d.changedTouches=j(e,a,b),b.dispatchEvent(d)}function f(a){var b=a.getBoundingClientRect();return{pageX:b.left,pageY:b.top}}function g(a){var b={};return b.clientX=a.hasOwnProperty("clientX")?a.clientX:0,b.clientY=a.hasOwnProperty("clientY")?a.clientY:0,b.pageX=a.hasOwnProperty("pageX")?a.pageX:0,b.pageY=a.hasOwnProperty("pageY")?a.pageY:0,b.screenX=a.hasOwnProperty("screenX")?a.screenX:0,b.screenY=a.hasOwnProperty("screenY")?a.screenY:0,b}function h(c,d){var e=new b;return e.push(new a(d,1,c,0,0)),e}function i(a,c,d){var e=new b;return"touchend"!==c&&(e=h(a,d)),e}function j(a,b,c){var d=h(a,c);return("touchstart"===b||"touchend"===b)&&d.splice(0,1),d}document.createTouch||(document.createTouch=function(b,c,d,e,f,g,h,i,j){return(void 0===i||void 0===j)&&(i=e-window.pageXOffset,j=f-window.pageYOffset),new a(c,d,{pageX:e,pageY:f,screenX:g,screenY:h,clientX:i,clientY:j})}),document.createTouchList||(document.createTouchList=function(){for(var a=new b,c=0;c<arguments.length;c++)a[c]=arguments[c];return a.length=arguments.length,a}),"undefined"==typeof window.TouchFaker&&(window.TouchFaker={}),window.TouchFaker.multiTouchOffset=75,window.TouchFaker.init=function(){d()||c()}(),window.TouchFaker.fakeEvent=function(a,b,c){var d=b;if("string"==typeof b&&(d=document.querySelector(b)),!d)throw new Error("Target cannot be found");if(-1===a.indexOf("touch"))throw new Error("Not a touch event");if("undefined"!=typeof c&&"object"!=typeof c)throw new Error("Params has to be an Object");e(a,d,c)}}(); |
Loading…
Reference in new issue