Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iliketomatoes committed Nov 18, 2014
1 parent 977714f commit c54de24
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 110 deletions.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -187,6 +187,9 @@ Not tested yet, but working on all modern browser, IE9+.

##CHANGELOG

###v 0.3.1
Starting tests

###v 0.3.0
Initial release with touch events and drag events enabled

Expand All @@ -202,7 +205,7 @@ Initial release
##ROADMAP
+ Better API
+ Better touch events
+ Tests
+ Better Tests

##LICENSE
MIT
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "elbajs",
"version": "0.3.0",
"version": "0.3.1",
"homepage": "https://github.com/iliketomatoes/elbajs",
"authors": [
"Giancarlo Soverini <giancarlosoverini@gmail.com>"
Expand Down
21 changes: 16 additions & 5 deletions dist/elba/elba.js
@@ -1,4 +1,4 @@
/*! elba - v0.3.0 - 2014-11-18
/*! elba - v0.3.1 - 2014-11-18
* https://github.com/iliketomatoes/elbajs
* Copyright (c) 2014 ; Licensed */
;(function(elba) {
Expand Down Expand Up @@ -187,6 +187,11 @@ var easingObj = {
//Elba constructor
function Elba( el, settings ) {

if(typeof el === 'undefined') {
console.error('missing target');
throw new Error();
}

//Declare an object holding the main parts of the gallery
this.base = {
el : el,
Expand Down Expand Up @@ -224,12 +229,15 @@ function Elba( el, settings ) {
* Store the slides into _base.slides array
* @param {Object} _base
*/
var _createSlideArray = function(_base,_options){
var parent = _base.el || document;
var nodelist = parent.querySelectorAll(_options.selector);
_base.count = nodelist.length;
var _createSlideArray = function(_base,_options){

var nodelist = _base.el.querySelectorAll(_options.selector);

_base.count = nodelist.length;
//converting nodelist to array
for(var i = _base.count; i--; _base.slides.unshift(nodelist[i])){}

return true;
};

/**
Expand Down Expand Up @@ -392,6 +400,8 @@ var _lazyLoadImages = function(_base, _options, loadIndex){
var loaderPointer = loadIndex || _base.pointer;
var ele = _base.slides[loaderPointer];

if(!!!ele) return false;

if(isElementLoaded(ele, _options.successClass) || isElementLoaded(ele, _options.errorClass)){
_loadNext(_base, _options, loaderPointer);
}
Expand Down Expand Up @@ -1248,5 +1258,6 @@ function setListener(elm, events, callback) {
elm.addEventListener(eventsArray[i], callback, false);
}
}

return Elba;
});
4 changes: 2 additions & 2 deletions dist/elba/elba.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "elba",
"version": "0.3.0",
"version": "0.3.1",
"description": "RWD, multi-serving, pure javascript gallery",
"scripts": {
"start": "node_modules/.bin/supervisor app",
Expand Down
5 changes: 5 additions & 0 deletions src/elbaconstructor.js
Expand Up @@ -46,6 +46,11 @@ var easingObj = {
//Elba constructor
function Elba( el, settings ) {

if(typeof el === 'undefined') {
console.error('missing target');
throw new Error();
}

//Declare an object holding the main parts of the gallery
this.base = {
el : el,
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.js
Expand Up @@ -93,4 +93,4 @@ function setListener(elm, events, callback) {
while (i--) {
elm.addEventListener(eventsArray[i], callback, false);
}
}
}
13 changes: 9 additions & 4 deletions src/privatemethods.js
Expand Up @@ -7,12 +7,15 @@ PRIVATE METHODS
* Store the slides into _base.slides array
* @param {Object} _base
*/
var _createSlideArray = function(_base,_options){
var parent = _base.el || document;
var nodelist = parent.querySelectorAll(_options.selector);
_base.count = nodelist.length;
var _createSlideArray = function(_base,_options){

var nodelist = _base.el.querySelectorAll(_options.selector);

_base.count = nodelist.length;
//converting nodelist to array
for(var i = _base.count; i--; _base.slides.unshift(nodelist[i])){}

return true;
};

/**
Expand Down Expand Up @@ -175,6 +178,8 @@ var _lazyLoadImages = function(_base, _options, loadIndex){
var loaderPointer = loadIndex || _base.pointer;
var ele = _base.slides[loaderPointer];

if(!!!ele) return false;

if(isElementLoaded(ele, _options.successClass) || isElementLoaded(ele, _options.errorClass)){
_loadNext(_base, _options, loaderPointer);
}
Expand Down
11 changes: 0 additions & 11 deletions test/addition.js

This file was deleted.

17 changes: 0 additions & 17 deletions test/cow.js

This file was deleted.

28 changes: 0 additions & 28 deletions test/cow_test.js

This file was deleted.

29 changes: 8 additions & 21 deletions test/elba_test.js
@@ -1,30 +1,17 @@
var expect = chai.expect;
var target = document.getElementById("fake-gallery");
var gallery = document.getElementById("real-gallery");
var emptyGallery = new Elba(document.getElementById("empty-gallery"));

describe("Elba", function() {
describe("constructor", function() {
it("should have a target", function() {
console.log(target);
var elba = new Elba(target);
expect(elba.base).to.be.a("object");

it("should be ok if the gallery doesn't contain any slide", function() {
expect(emptyGallery.base.slides).to.be.a("Array");
});

/*it("should have a pointer", function() {
var pointer = new Elba(target).getCurrent();
expect(pointer).to.be.a("number");
});*/
});

/*describe("#greets", function() {
it("should throw if no target is passed in", function() {
expect(function() {
(new Cow()).greets();
}).to.throw(Error);
it("should throw an Error when you don't pass any argument to the constructor", function() {
expect(function(){ new Elba(); }).to.throw(Error);
});
});

it("should greet passed target", function() {
var greetings = (new Cow("Kate")).greets("Baby");
expect(greetings).to.equal("Kate greets Baby");
});
});*/
});
26 changes: 8 additions & 18 deletions test/tests.html
Expand Up @@ -10,7 +10,9 @@
<div id="mocha"><p><a href=".">Index</a></p></div>
<div id="messages"></div>
<div id="fixtures"></div>
<figure id="fake-gallery" class="elba-carousel">

<!-- Real Gallery -->
<figure id="gallery" class="elba-carousel">
<figure class="elba" data-src="http://www.placebear.com/768/400" data-src-medium="http://www.placebear.com/1080/650" data-src-large="http://www.placebear.com/1400/800">
<figcaption class="elba-content">
<div class="elba-banner">
Expand All @@ -20,27 +22,15 @@ <h1>elba js</h1>
</div>
</figcaption>
</figure>

<!-- Empty Gallery -->
<figure id="empty-gallery" class="elba-carousel">
</figure>
<script type="text/javascript">
!(function(){
var gallery = document.getElementById("fake-gallery");

var elba = new Elba(gallery,{
breakpoints: [{
width: 768 // min-width
, src: 'data-src-medium'
}
, {
width: 1080 // min-width
, src: 'data-src-large'
}]
});
})();
</script>
<!--<script src="vendor/mocha.js"></script>
<script src="vendor/mocha.js"></script>
<script src="vendor/chai.js"></script>
<script>mocha.setup('bdd')</script>
<script src="elba_test.js"></script>
<script>mocha.run();</script>-->
<script>mocha.run();</script>
</body>
</html>

0 comments on commit c54de24

Please sign in to comment.