Repository navigation
Expand file tree
/
Copy pathfeatherlight_gallery_test.js
More file actions
53 lines (48 loc) · 1.82 KB
/
Copy pathfeatherlight_gallery_test.js
File metadata and controls
53 lines (48 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var expect = chai.expect;
(function($) {
var $htmlFixtures = null;
var resetFixtures = function(){
if (!$htmlFixtures) $htmlFixtures = $('#fixtures').detach();
$('body >:not(#mocha)').remove()
$('body').append($htmlFixtures.clone(true));
};
$.fx.off = true;
describe('Featherlight Gallery', function() {
beforeEach(resetFixtures);
after(resetFixtures);
it ('works as expected', function(done) {
$('#basic-test a').featherlightGallery();
$('#basic-test a').eq(2).click();
patiently(done, [function() {
expect($('.featherlight img')).to.have.attr('src').match(/photo_large.jpg\?2/);
$('.featherlight').trigger('next');
}, function() {
expect($('.featherlight img')).to.have.attr('src').match(/photo_large.jpg\?3/);
$('.featherlight').trigger('next');
}, function() {
expect($('.featherlight img')).to.have.attr('src').match(/photo_large.jpg\?0/);
$('.featherlight').trigger('previous');
}, function() {
expect($('.featherlight img')).to.have.attr('src').match(/photo_large.jpg\?3/);
}]);
});
it ('is chainable', function() {
var $anchors = $('#basic-test a');
expect($anchors.featherlight()).to.equal($anchors);
});
it ('accepts an afterImage config', function(done) {
var lastCurrent = null;
$('#basic-test a').featherlightGallery({
afterImage: function() { lastCurrent = this.$currentTarget; }
});
$('#basic-test a').eq(2).click();
patiently(done, [function(){
expect(lastCurrent).to.not.be.null
expect(lastCurrent).to.have.attr('href').match(/photo_large.jpg\?2/);
$('.featherlight').trigger('next');
}, function() {
expect(lastCurrent).to.have.attr('href').match(/photo_large.jpg\?3/);
}]);
});
});
}(jQuery));