2015-05-12 09:07:58 +08:00
|
|
|
React = require 'react'
|
|
|
|
ReactTestUtils = React.addons.TestUtils
|
|
|
|
|
|
|
|
SearchBar = require '../lib/search-bar'
|
2016-01-12 07:58:10 +08:00
|
|
|
SearchActions = require '../lib/search-actions'
|
2015-05-22 05:41:30 +08:00
|
|
|
SearchSuggestionStore = require '../lib/search-suggestion-store'
|
2015-05-12 09:07:58 +08:00
|
|
|
|
|
|
|
describe 'SearchBar', ->
|
|
|
|
beforeEach ->
|
2015-11-12 02:25:11 +08:00
|
|
|
spyOn(NylasEnv, "isMainWindow").andReturn true
|
2015-05-12 09:07:58 +08:00
|
|
|
@searchBar = ReactTestUtils.renderIntoDocument(<SearchBar />)
|
|
|
|
input = ReactTestUtils.findRenderedDOMComponentWithTag(@searchBar, "input")
|
|
|
|
@input = React.findDOMNode(input)
|
|
|
|
|
|
|
|
it 'supports search queries with a colon character', ->
|
2016-01-12 07:58:10 +08:00
|
|
|
spyOn(SearchActions, "queryChanged")
|
2015-05-12 09:07:58 +08:00
|
|
|
test = "::Hello: World::"
|
|
|
|
ReactTestUtils.Simulate.change @input, target: value: test
|
2016-01-12 08:08:59 +08:00
|
|
|
expect(SearchActions.queryChanged).toHaveBeenCalledWith([all: test])
|
2015-05-16 01:45:18 +08:00
|
|
|
|
2016-01-12 07:58:10 +08:00
|
|
|
it 'preserves capitalization on searches', ->
|
2015-05-16 01:45:18 +08:00
|
|
|
test = "HeLlO wOrLd"
|
|
|
|
ReactTestUtils.Simulate.change @input, target: value: test
|
|
|
|
waitsFor =>
|
|
|
|
@input.value.length > 0
|
|
|
|
runs =>
|
2016-01-12 07:58:10 +08:00
|
|
|
expect(@input.value).toBe(test)
|