2015-05-12 09:07:58 +08:00
|
|
|
React = require 'react'
|
2016-03-29 16:41:24 +08:00
|
|
|
ReactDOM = require 'react-dom'
|
|
|
|
ReactTestUtils = require('react-addons-test-utils')
|
2015-05-12 09:07:58 +08:00
|
|
|
|
|
|
|
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 />)
|
2016-03-29 16:41:24 +08:00
|
|
|
@input = ReactDOM.findDOMNode(@searchBar).querySelector("input")
|
2015-05-12 09:07:58 +08:00
|
|
|
|
|
|
|
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:16:35 +08:00
|
|
|
expect(SearchActions.queryChanged).toHaveBeenCalledWith(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)
|