-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: send hostname * test: add test for send hostname
- Loading branch information
1 parent
be6674a
commit 799c0af
Showing
10 changed files
with
149 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,111 @@ | ||
var AutoComplete = require('../src/js/autoComplete'); | ||
var snippet = require('tui-code-snippet'); | ||
|
||
describe('자동완성 컴포넌트를 생성하고 기능을 테스트한다.', function() { | ||
var autoComplete, | ||
resultManager, | ||
inputManager, | ||
global = tui.test.global; | ||
|
||
beforeEach(function() { | ||
loadFixtures('expand.html'); | ||
$('#ac_input1').val('운동화'); | ||
describe('functions', function() { | ||
beforeEach(function() { | ||
loadFixtures('expand.html'); | ||
$('#ac_input1').val('운동화'); | ||
|
||
// 객체 생성 | ||
autoComplete = new AutoComplete({'config': global.Default}); | ||
resultManager = autoComplete.resultManager; | ||
inputManager = autoComplete.inputManager; | ||
}); | ||
// 객체 생성 | ||
autoComplete = new AutoComplete({'config': global.Default}); | ||
resultManager = autoComplete.resultManager; | ||
inputManager = autoComplete.inputManager; | ||
}); | ||
|
||
// OK | ||
it('AutoComplete, Manager 객체가 생성되는지 테스트한다.', function() { | ||
var A = new AutoComplete({ | ||
config: global.Default | ||
}); | ||
|
||
expect(A).toEqual(jasmine.any(Object)); | ||
|
||
// 객체 생성 판단 | ||
resultManager = A.resultManager; | ||
inputManager = A.inputManager; | ||
|
||
// OK | ||
it('AutoComplete, Manager 객체가 생성되는지 테스트한다.', function() { | ||
var A = new AutoComplete({ | ||
config: global.Default | ||
expect(inputManager).toBeTruthy(); | ||
expect(resultManager).toBeTruthy(); | ||
}); | ||
|
||
expect(A).toEqual(jasmine.any(Object)); | ||
it('키워드 하이라이팅이 제대로 되는가.', function() { | ||
resultManager = autoComplete.resultManager; | ||
|
||
// 객체 생성 판단 | ||
resultManager = A.resultManager; | ||
inputManager = A.inputManager; | ||
// 검색어 입력 | ||
autoComplete.setValue('운동화'); | ||
autoComplete.request('운동화'); | ||
|
||
expect(inputManager).toBeTruthy(); | ||
expect(resultManager).toBeTruthy(); | ||
}); | ||
// 키워드 하이라이트 처리 테스트 | ||
autoComplete.queries = ['나이키']; | ||
expect(resultManager._highlight('나이키 에어')).toBe('<strong>나이키</strong> 에어'); | ||
autoComplete.queries = ['TEST']; | ||
expect(resultManager._highlight('나이키 에어')).toBe('나이키 에어'); | ||
}); | ||
|
||
it('키워드 하이라이팅이 제대로 되는가.', function() { | ||
resultManager = autoComplete.resultManager; | ||
// OK | ||
it('자동완성 기능을 사용안함으로 설정되는가.', function() { | ||
// 자동완성 기능 사용 안함 설정 | ||
autoComplete.setCookieValue(false); | ||
expect(autoComplete.isUseAutoComplete()).toBeFalsy(); | ||
autoComplete.hideResultList(); | ||
}); | ||
|
||
// 검색어 입력 | ||
autoComplete.setValue('운동화'); | ||
autoComplete.request('운동화'); | ||
it('(검색어 결과가 있는 경우)검색어 입력 후, 검색 결과가 있는가.', function() { | ||
var eventMock = { | ||
stopPropagation: function() {} | ||
}; | ||
|
||
// 키워드 하이라이트 처리 테스트 | ||
autoComplete.queries = ['나이키']; | ||
expect(resultManager._highlight('나이키 에어')).toBe('<strong>나이키</strong> 에어'); | ||
autoComplete.queries = ['TEST']; | ||
expect(resultManager._highlight('나이키 에어')).toBe('나이키 에어'); | ||
}); | ||
autoComplete.setCookieValue(true); | ||
autoComplete.setValue('운동화'); | ||
|
||
// OK | ||
it('자동완성 기능을 사용안함으로 설정되는가.', function() { | ||
// 자동완성 기능 사용 안함 설정 | ||
autoComplete.setCookieValue(false); | ||
expect(autoComplete.isUseAutoComplete()).toBeFalsy(); | ||
autoComplete.hideResultList(); | ||
}); | ||
expect($('._resultBox')).not.toBeEmpty(); | ||
expect($('._resultBox > li')).not.toBeEmpty(); | ||
expect(inputManager).toBeDefined(); | ||
|
||
autoComplete.setCookieValue(false); | ||
inputManager._onClickToggle(eventMock); | ||
}); | ||
|
||
it('(검색어 결과가 있는 경우)검색어 입력 후, 검색 결과가 있는가.', function() { | ||
var eventMock = { | ||
stopPropagation: function() {} | ||
}; | ||
it('자동완성 끄기/켜기 기능이 제대로 동작하는가.', function() { | ||
var $onOffTxt = $('.baseBox .bottom'); | ||
|
||
autoComplete.setCookieValue(true); | ||
autoComplete.setValue('운동화'); | ||
resultManager.changeOnOffText(true); | ||
expect($('#onofftext').text()).toEqual('자동완성 끄기'); | ||
|
||
expect($('._resultBox')).not.toBeEmpty(); | ||
expect($('._resultBox > li')).not.toBeEmpty(); | ||
expect(inputManager).toBeDefined(); | ||
resultManager.changeOnOffText(false); | ||
expect($onOffTxt.css('display')).toEqual('none'); | ||
|
||
autoComplete.setCookieValue(false); | ||
inputManager._onClickToggle(eventMock); | ||
resultManager._useAutoComplete(); | ||
expect(resultManager.isShowResultList()).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
it('자동완성 끄기/켜기 기능이 제대로 동작하는가.', function() { | ||
var $onOffTxt = $('.baseBox .bottom'); | ||
// hostnameSent module scope variable can not be reset. | ||
// maintain cases with xit as it always fail, if you want to test these cases, change xit to fit one by one | ||
describe('usageStatistics', function() { | ||
beforeEach(function() { | ||
spyOn(snippet, 'imagePing'); | ||
}); | ||
|
||
xit('should send hostname by default', function() { | ||
autoComplete = new AutoComplete({'config': global.Default}); | ||
|
||
resultManager.changeOnOffText(true); | ||
expect($('#onofftext').text()).toEqual('자동완성 끄기'); | ||
expect(snippet.imagePing).toHaveBeenCalled(); | ||
}); | ||
|
||
resultManager.changeOnOffText(false); | ||
expect($onOffTxt.css('display')).toEqual('none'); | ||
xit('should not send hostname on usageStatistics option false', function() { | ||
autoComplete = new AutoComplete({ | ||
'config': global.Default, | ||
usageStatistics: false | ||
}); | ||
|
||
resultManager._useAutoComplete(); | ||
expect(resultManager.isShowResultList()).toBeFalsy(); | ||
expect(snippet.imagePing).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); |