Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #774 from Johann-S/unit_test
Add unit test to Ratchet
- Loading branch information
Showing
9 changed files
with
213 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -39,3 +39,4 @@ docs/.jekyll-metadata | |
# Folders to ignore | ||
node_modules | ||
bower_components | ||
.grunt |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"devel" : true, | ||
"es3" : false, | ||
"jasmine" : true | ||
} |
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,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> |
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,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); | ||
}); | ||
}); |
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,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); | ||
}); | ||
}); |
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,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'); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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