switch (type) {
case 'image':
case 'background':
- return `_build/assets/img/interchange/${size}.jpg`;
+ return `_build/assets/img/interchange/${size}.jpg`;
default:
return `_build/assets/partials/interchange-${size}.html`;
}
[${getPath(type, 'small')}, small],
[${getPath(type, 'medium')}, medium],
[${getPath(type, 'large')}, large]
- ">`;
+ ">`;
case 'background':
return `<div data-interchange="
[${getPath(type, 'small')}, small],
plugin = new Foundation.Interchange($html, {});
var spy = sinon.spy($, 'get');
-
+
plugin.replace(getPath('template', 'large'));
sinon.assert.calledWith(spy, getPath('template', 'large'));
- spy.restore();
+ spy.restore();
});
it('fires replaced.zf.interchange event', function() {
$html.on('replaced.zf.interchange', spy);
plugin.replace(getPath('image', 'large'));
-
+
sinon.assert.called(spy);
});
});
it('calls reflow on viewport size change once', function(done) {
$html = $(generateTemplate('image')).appendTo('body');
plugin = new Foundation.Interchange($html, {});
-
+ Foundation.IHearYou();
let spy = sinon.spy(plugin, '_reflow');
-
- $(window).trigger('resize');
setTimeout(function() {
$(window).trigger('resize');
- }, 30);
+ }, 1);
setTimeout(function() {
$(window).trigger('resize');
- }, 60);
+ }, 5);
- setTimeout(function() { // Wait for third trigger...
+ setTimeout(function() {
$(window).trigger('resize');
+ }, 10);
+
+ setTimeout(function() { // Wait for third trigger...
sinon.assert.calledOnce(spy);
done();
- }, 60);
+ }, 50);
});
});
-});
\ No newline at end of file
+});