2015-05-12 09:07:58 +08:00
|
|
|
React = require 'react'
|
|
|
|
ReactTestUtils = React.addons.TestUtils
|
|
|
|
|
2015-05-15 08:08:30 +08:00
|
|
|
{Actions} = require 'nylas-exports'
|
2015-05-12 09:07:58 +08:00
|
|
|
|
|
|
|
SearchBar = require '../lib/search-bar'
|
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-09-23 07:40:33 +08:00
|
|
|
spyOn(atom, "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', ->
|
|
|
|
spyOn(Actions, "searchQueryChanged")
|
|
|
|
test = "::Hello: World::"
|
|
|
|
ReactTestUtils.Simulate.change @input, target: value: test
|
|
|
|
expect(Actions.searchQueryChanged).toHaveBeenCalledWith [all: test]
|
2015-05-16 01:45:18 +08:00
|
|
|
|
|
|
|
it 'preserves capitalization on seraches', ->
|
|
|
|
test = "HeLlO wOrLd"
|
|
|
|
ReactTestUtils.Simulate.change @input, target: value: test
|
|
|
|
waitsFor =>
|
|
|
|
@input.value.length > 0
|
|
|
|
runs =>
|
|
|
|
expect(@input.value).toBe test
|