Skip to content

Commit

Permalink
better copy for current tests and start adding dom related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stereobit committed Mar 18, 2014
1 parent a698e69 commit 7a9ea4f
Showing 1 changed file with 39 additions and 19 deletions.
58 changes: 39 additions & 19 deletions test/spec/test.js
Expand Up @@ -9,7 +9,7 @@ define(['dragend'], function(Dragend) {

describe('create instance', function() {

it('check if settings are inherited', function() {
it('should inherited settings', function() {
var instance = new Dragend(createDom(), {
duration: 14,
onDrag: function() {}
Expand All @@ -19,47 +19,67 @@ define(['dragend'], function(Dragend) {
expect(instance.settings.onDrag).to.be.a('function');
});

it('check if jQuery creates instance', function() {
it('should create instance using the jQuery object', function() {
var instance = $(createDom()).dragend();

expect(instance.data('dragend')).to.be.an(Dragend);
expect(instance).to.be.an(jQuery);
});

it('check if content gets copied into new container', function() {
var instance = new Dragend(createDom());

expect(instance.container.childNodes[0].className).not.to.equal('dragend-page');
it('should copy the content into new container', function() {
expect(new Dragend(createDom()).container.childNodes[0].className).not.to.equal('dragend-page');
});


it('check if pages size got set right', function() {
it('should set the pages size to the same size as the container', function() {
var instance = new Dragend(createDom());

expect(instance.container.childNodes[0].childNodes[0].offsetWidth).to.eql(instance.container.offsetWidth);
});

it.skip('scribe option', function() {
it.skip('itemsInPage option', function() {
var instance = new Dragend(createDom(), {
scribe: "10px"
itemsInPage: 2
});

expect(instance.container.childNodes[0].childNodes[0].offsetWidth).to.eql(90);
expect(instance.container.childNodes[0].childNodes[0].offsetWidth).to.eql(50);
});

it.skip('itemsInPage option', function() {
var instance = new Dragend(createDom(), {
itemsInPage: 2
});

describe('update dom and initialize', function() {

describe('pages count', function() {

var instance;

before(function(done) {
instance = new Dragend(createDom(), {
afterInitialize: done
});
});

it('should return the count of elements with the class dragend-page', function() {
expect(instance.pagesCount).to.be(3);
});

expect(instance.container.childNodes[0].childNodes[0].offsetWidth).to.eql(50);
});

it.skip('check if pages are found', function() {
var instance = new Dragend(createDom());
describe('scribe option', function() {

var instance;

before(function(done) {
instance = new Dragend(createDom(), {
afterInitialize: done,
scribe: "10px"
});
});

it.skip('should scale the width of every page reduced by the scribe distance', function() {
console.log(instance.container.childNodes[0].childNodes[0])
expect(instance.container.childNodes[0].childNodes[0].offsetWidth).to.eql(90);
});

expect(instance.pages.length).to.be(3);
expect(instance.pagesCount).to.be(3);
});

});
Expand Down

0 comments on commit 7a9ea4f

Please sign in to comment.