You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
3.0 KiB
CoffeeScript
106 lines
3.0 KiB
CoffeeScript
13 years ago
|
describe 'AsciiIo.PlayerView', ->
|
||
13 years ago
|
element = null
|
||
|
cols = 2
|
||
|
lines = 5
|
||
|
data = ''
|
||
|
timing = []
|
||
|
|
||
|
beforeEach ->
|
||
|
element = $('<div>')
|
||
|
|
||
|
describe 'constructor', ->
|
||
|
it 'creates needed DOM elements inside player element', ->
|
||
13 years ago
|
player = new AsciiIo.PlayerView({
|
||
|
el: element, cols: cols, lines: lines, data: data, timing: timing
|
||
|
})
|
||
|
|
||
13 years ago
|
expect(element.find('.terminal').length).toBe(1)
|
||
|
expect(element.find('.hud').length).toBe(1)
|
||
|
|
||
|
it 'creates TerminalView instance passing proper DOM element', ->
|
||
13 years ago
|
spyOn(AsciiIo, 'TerminalView').andReturn({ on: -> 'foo' })
|
||
|
|
||
|
player = new AsciiIo.PlayerView({
|
||
|
el: element, cols: cols, lines: lines, data: data, timing: timing
|
||
|
})
|
||
|
|
||
|
expect(AsciiIo.TerminalView).toHaveBeenCalledWith({
|
||
13 years ago
|
cols: cols, lines: lines
|
||
13 years ago
|
})
|
||
13 years ago
|
|
||
|
it 'creates HudView instance passing proper DOM element', ->
|
||
13 years ago
|
spyOn(AsciiIo, 'HudView').andReturn({ on: -> 'foo' })
|
||
13 years ago
|
|
||
|
player = new AsciiIo.PlayerView({
|
||
|
el: element, cols: cols, lines: lines, data: data, timing: timing
|
||
|
})
|
||
|
|
||
13 years ago
|
expect(AsciiIo.HudView).toHaveBeenCalled()
|
||
13 years ago
|
|
||
|
it 'creates Movie instance', ->
|
||
13 years ago
|
spyOn(AsciiIo, 'Movie').andCallThrough()
|
||
|
|
||
|
player = new AsciiIo.PlayerView({
|
||
|
el: element, cols: cols, lines: lines, data: data, timing: timing
|
||
|
})
|
||
|
|
||
13 years ago
|
expect(AsciiIo.Movie).toHaveBeenCalledWith(data, timing)
|
||
|
|
||
|
describe 'events', ->
|
||
13 years ago
|
player = null
|
||
|
|
||
|
beforeEach ->
|
||
13 years ago
|
player = new AsciiIo.PlayerView({
|
||
|
el: element, cols: cols, lines: lines, data: data, timing: timing
|
||
|
})
|
||
13 years ago
|
|
||
|
it 'toggles movie playback when terminal-click is fired on terminal', ->
|
||
13 years ago
|
spyOn player.movie, 'togglePlay'
|
||
|
|
||
13 years ago
|
player.terminalView.trigger 'terminal-click'
|
||
13 years ago
|
|
||
|
expect(player.movie.togglePlay).toHaveBeenCalled()
|
||
13 years ago
|
|
||
|
it 'toggles movie playback when hud-play-click is fired on hud', ->
|
||
13 years ago
|
spyOn player.movie, 'togglePlay'
|
||
|
|
||
|
player.hudView.trigger 'hud-play-click'
|
||
|
|
||
|
expect(player.movie.togglePlay).toHaveBeenCalled()
|
||
13 years ago
|
|
||
|
it 'seeks movie playback when hud-seek-click is fired on hud', ->
|
||
13 years ago
|
spyOn player.movie, 'seek'
|
||
|
|
||
|
player.hudView.trigger 'hud-seek-click', 55
|
||
|
|
||
|
expect(player.movie.seek).toHaveBeenCalledWith(55)
|
||
13 years ago
|
|
||
|
it 'toggles fullscreen view when hud-fullscreen-click is fired on hud', ->
|
||
13 years ago
|
# pending functionality
|
||
13 years ago
|
|
||
|
it 'stops cursor blinking when movie-finished is fired on movie', ->
|
||
13 years ago
|
spyOn player.terminalView, 'stopCursorBlink'
|
||
|
|
||
|
player.movie.trigger 'movie-finished'
|
||
|
|
||
|
expect(player.terminalView.stopCursorBlink).toHaveBeenCalled()
|
||
|
|
||
|
it 'feeds interpreter when movie-frame is fired on movie', ->
|
||
|
frame = { some: 'Frame' }
|
||
13 years ago
|
spyOn player.vt, 'feed'
|
||
13 years ago
|
|
||
|
player.movie.trigger 'movie-frame', frame
|
||
|
|
||
13 years ago
|
expect(player.vt.feed).toHaveBeenCalledWith(frame)
|
||
13 years ago
|
|
||
|
describe '#play', ->
|
||
|
it 'starts movie playback', ->
|
||
|
player = new AsciiIo.PlayerView({
|
||
|
el: element, cols: cols, lines: lines, data: data, timing: timing
|
||
|
})
|
||
|
spyOn player.movie, 'play'
|
||
|
|
||
|
player.play()
|
||
13 years ago
|
|
||
13 years ago
|
expect(player.movie.play).toHaveBeenCalled()
|