Skip to content

Commit

Permalink
Add unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
faebeee committed Oct 23, 2018
1 parent 4bb02d3 commit 4f3a267
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/filters/bgImage/bgImage.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { expect } from 'chai';
import bgImageFilter from './index';

describe('bgImage Filter', () => {
it('create style o object', () => {
const url = 'http://via.placeholder.com/400x400';
const style = bgImageFilter(url);

expect(style['background-image']).to.be.equal(`url(${ url })`);
});
});
34 changes: 34 additions & 0 deletions src/filters/srcset/srcset.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { expect } from 'chai';
import srcsetFilter from './index';

describe('srcset Filter', () => {
it('srcset with one image', () => {
const urls = [
'http://via.placeholder.com/400x400',
];
const srcset = srcsetFilter(urls);

expect(srcset).to.be.equal(``);
});

it('srcset with two images', () => {
const urls = [
'http://via.placeholder.com/400x400',
'http://via.placeholder.com/800x800',
];
const srcset = srcsetFilter(urls);

expect(srcset).to.be.equal(`${ urls[0] } 1x, ${ urls[1] } 2x`);
});

it('srcset with three images', () => {
const urls = [
'http://via.placeholder.com/400x400',
'http://via.placeholder.com/800x800',
'http://via.placeholder.com/1600x1600',
];
const srcset = srcsetFilter(urls);

expect(srcset).to.be.equal(`${ urls[0] } 1x, ${ urls[1] } 2x, ${ urls[2] } 3x`);
});
});

0 comments on commit 4f3a267

Please sign in to comment.