mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add init test for SpellCheckManager
This commit is contained in:
parent
034531d323
commit
9c56f6c2fc
1 changed files with 46 additions and 0 deletions
|
@ -0,0 +1,46 @@
|
|||
define [
|
||||
'ide/editor/directives/aceEditor/spell-check/SpellCheckManager'
|
||||
], (SpellCheckManager) ->
|
||||
describe 'SpellCheckManager', ->
|
||||
beforeEach (done) ->
|
||||
@timelord = sinon.useFakeTimers()
|
||||
|
||||
window.user = { id: 1 }
|
||||
window.csrfToken = 'token'
|
||||
@scope = {
|
||||
$watch: sinon.stub()
|
||||
spellCheck: true
|
||||
spellCheckLanguage: 'en'
|
||||
}
|
||||
@wordManager = {
|
||||
reset: sinon.stub()
|
||||
clearRow: sinon.stub()
|
||||
addHighlight: sinon.stub()
|
||||
}
|
||||
@adapter = {
|
||||
getLines: sinon.stub()
|
||||
wordManager: @wordManager
|
||||
}
|
||||
inject ($q, $http, $httpBackend, $cacheFactory) =>
|
||||
@$http = $http
|
||||
@$q = $q
|
||||
@$httpBackend = $httpBackend
|
||||
cache = $cacheFactory('spellCheckTest', {capacity: 1000})
|
||||
@spellCheckManager = new SpellCheckManager(@scope, cache, $http, $q, @adapter)
|
||||
done()
|
||||
|
||||
afterEach ->
|
||||
@timelord.restore()
|
||||
|
||||
it 'runs a full check soon after init', () ->
|
||||
@$httpBackend.when('POST', '/spelling/check').respond({
|
||||
misspellings: [{
|
||||
index: 0
|
||||
suggestions: ['opposition']
|
||||
}]
|
||||
})
|
||||
@adapter.getLines.returns(['oppozition'])
|
||||
@spellCheckManager.init()
|
||||
@timelord.tick(200)
|
||||
@$httpBackend.flush()
|
||||
expect(@wordManager.addHighlight).to.have.been.called
|
Loading…
Reference in a new issue