howl.inputs.search_inputs

registers a "forward_search" input

assert.not_nil inputs.forward_search

forward_search input

local searcher, input

before_each ->
  searcher = {}
  app.editor = :searcher
  input = inputs.forward_search!

after_each -> app.editor = nil

should_complete() returns true

assert.is_true input\should_complete!

complete(text) searches forward for <text>

searcher.forward_to = spy.new -> true
input\complete 'foo'
assert.spy(searcher.forward_to).was.called_with searcher, 'foo'

on_cancelled() calls cancel() on the searcher

searcher.cancel = spy.new -> true
input\on_cancelled!
assert.spy(searcher.cancel).was.called_with searcher

value_for(text) returns <text>

assert.equal 'foo', input\value_for 'foo'

replace input

local input, readline

before_each ->
  input = inputs.replace!
  readline = prompt: 'replace ', text: ''

on_submit

(when no target has been specified yet)

returns false

assert.is_false input\on_submit 'foo', readline

changes the prompt to show the selected target and resets the text

input\on_submit 'foo', readline
assert.equals "replace 'foo' with ", readline.prompt
assert.equals "", readline.text

(when target has been specified already)

returns non-false

input\on_submit 'foo', readline
assert.is_not_false input\on_submit 'bar', readline

returns non-false even for an empty string

input\on_submit 'foo', readline
assert.is_not_false input\on_submit '', readline

value_for

returns a table containing target and replacement

input\on_submit 'foo', readline
input\on_submit 'bar', readline
assert.same { 'foo', 'bar' }, input\value_for 'bar', readline