Skip to content

Commit 531e6c9

Browse files
updated: unit test
1 parent 7128220 commit 531e6c9

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require('jsdom-global')()
22

33
const assert = require('assert')
4-
const { loadImage, loadImages } = require('./')
4+
const imagesLoader = require('./')
55

66

77
const LOAD_FAILURE_SRC = 'succes.jpg'
@@ -21,10 +21,18 @@ Object.defineProperty(global.Image.prototype, 'src', {
2121

2222

2323
describe('Bianco images-loader', function() {
24+
25+
it('export default contains all the module methods', function() {
26+
assert.deepEqual(Object.keys(imagesLoader.default), [
27+
'loadImage',
28+
'loadImages'
29+
])
30+
})
31+
2432
it('It can load images in the DOM', function(done) {
2533
const img = document.createElement('img')
2634

27-
loadImage(img).then(function(i) {
35+
imagesLoader.loadImage(img).then(function(i) {
2836
assert.ok(i)
2937
done()
3038
})
@@ -36,7 +44,7 @@ describe('Bianco images-loader', function() {
3644
it('It can throw properly the errors', function(done) {
3745
const img = document.createElement('img')
3846

39-
loadImage(img).then(() => {
47+
imagesLoader.loadImage(img).then(() => {
4048
throw 'This image should be not loaded'
4149
}).catch(function(e) {
4250
assert.ok(e instanceof Error)
@@ -47,7 +55,7 @@ describe('Bianco images-loader', function() {
4755
})
4856

4957
it('It can load arrays of images urls', function(done) {
50-
loadImages([LOAD_SUCCESS_SRC, LOAD_SUCCESS_SRC]).then(function(imgs) {
58+
imagesLoader.loadImages([LOAD_SUCCESS_SRC, LOAD_SUCCESS_SRC]).then(function(imgs) {
5159
assert.equal(imgs.length, 2)
5260
done()
5361
})

0 commit comments

Comments
 (0)