progress bar

This commit is contained in:
Bala Clark 2015-07-18 20:20:02 +02:00
parent 7ddb94ad77
commit 33c57f75dc
11 changed files with 1705 additions and 2369 deletions

View file

@ -1,4 +1,5 @@
let assert = require('assert')
let spy = require('spy')
let ComicBook = require('../app/comic-book')
let srcs = [
'data:image/gif;base64,R0lGODlhAQABAPAAAKqqqv///yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==',
@ -49,7 +50,42 @@ describe('ComicBook', () => {
comic.preload()
})
it('should scroll to the top of the page on page turn')
it('should show the progress bar on preload:start', () => {
let comic = new ComicBook(srcs)
assert.equal(comic.progressBar.el.style.display, 'none')
comic.preload()
assert.equal(comic.progressBar.el.style.display, 'block')
})
it('should update the progress bar', done => {
let comic = new ComicBook(srcs)
comic.progressBar.update = spy()
comic.preload()
comic.on('preload:finish', () => {
assert.equal(comic.progressBar.update.callCount, 5)
assert(comic.progressBar.update.calls[0].calledWith(20))
assert(comic.progressBar.update.calls[1].calledWith(40))
assert(comic.progressBar.update.calls[2].calledWith(60))
assert(comic.progressBar.update.calls[3].calledWith(80))
assert(comic.progressBar.update.calls[4].calledWith(100))
done()
})
})
it('should hide the progress bar when finished', done => {
let comic = new ComicBook(srcs)
comic.preload()
comic.on('preload:finish', () => {
assert.equal(comic.progressBar.el.style.display, 'none')
done()
})
})
})
it('should scroll to the top of the page on page turn')
})

View file

@ -0,0 +1,32 @@
let assert = require('assert')
let ProgressBar = require('../../app/view/progress-bar')
describe('PreloadProgress', () => {
it('should show', () => {
let bar = new ProgressBar()
bar.el.style.display = 'none'
bar.show()
assert.equal(bar.el.style.display, 'block')
})
it('should hide', () => {
let bar = new ProgressBar()
bar.el.style.display = 'block'
bar.hide()
assert.equal(bar.el.style.display, 'none')
})
it('should show on when preload is started', () => {
let bar = new ProgressBar()
assert.equal(bar.el.style.display, 'none')
})
it('should show the current percentage of the total preloading images', () => {
let bar = new ProgressBar()
bar.update(50)
assert.equal(bar.progressEl.style.width, '50%')
})
})