Commit 32366d18 authored by Robert Speicher's avatar Robert Speicher

Rename BlobView to LineHighlighter

parent 1f88d9b5
......@@ -87,7 +87,7 @@ class Dispatcher
new TreeView()
shortcut_handler = new ShortcutsNavigation()
when 'projects:blob:show'
new BlobView()
new LineHighlighter()
shortcut_handler = new ShortcutsNavigation()
when 'projects:labels:new', 'projects:labels:edit'
new Labels()
......
# BlobView
# LineHighlighter
#
# Handles single- and multi-line selection and highlight for blob views.
#
......@@ -26,11 +26,11 @@
# </pre>
# </div>
# </div>
class @BlobView
class @LineHighlighter
# Internal copy of location.hash so we're not dependent on `location` in tests
@_hash = ''
# Initialize a BlobView object
# Initialize a LineHighlighter object
#
# hash - String URL hash for dependency injection in tests
constructor: (hash = location.hash) ->
......
#= require blob/blob
#= require line_highlighter
describe 'BlobView', ->
fixture.preload('blob.html')
describe 'LineHighlighter', ->
fixture.preload('line_highlighter.html')
clickLine = (number, eventData = {}) ->
if $.isEmptyObject(eventData)
......@@ -11,25 +11,25 @@ describe 'BlobView', ->
$("#L#{number}").trigger(e).click()
beforeEach ->
fixture.load('blob.html')
@class = new BlobView()
fixture.load('line_highlighter.html')
@class = new LineHighlighter()
@spies = {
__setLocationHash__: spyOn(@class, '__setLocationHash__').and.callFake ->
}
describe 'behavior', ->
it 'highlights one line given in the URL hash', ->
new BlobView('#L13')
new LineHighlighter('#L13')
expect($('#LC13')).toHaveClass('hll')
it 'highlights a range of lines given in the URL hash', ->
new BlobView('#L5-25')
new LineHighlighter('#L5-25')
expect($('.hll').length).toBe(21)
expect($("#LC#{line}")).toHaveClass('hll') for line in [5..25]
it 'scrolls to the first highlighted line on initial load', ->
spy = spyOn($, 'scrollTo')
new BlobView('#L5-25')
new LineHighlighter('#L5-25')
expect(spy).toHaveBeenCalledWith('#L5', jasmine.anything())
it 'discards click events', ->
......@@ -38,7 +38,7 @@ describe 'BlobView', ->
expect(spy).toHaveBeenPrevented()
it 'handles garbage input from the hash', ->
func = -> new BlobView('#tree-content-holder')
func = -> new LineHighlighter('#tree-content-holder')
expect(func).not.toThrow()
describe '#clickHandler', ->
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment