This commit is contained in:
Kristján Oddsson 2021-04-12 13:52:07 +01:00
Родитель 0f762f8234
Коммит eac805f714
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F5C58CF9F8FE5D63
1 изменённых файлов: 6 добавлений и 16 удалений

Просмотреть файл

@ -74,15 +74,13 @@ describe('text-expander element', function() {
const expander = document.querySelector('text-expander')
const input = expander.querySelector('textarea')
let calls = 0
const receivedText = {}
const receivedText = []
const expectedText = ['', 'a', 'ab', 'abc', 'abcd']
expander.addEventListener('text-expander-change', event => {
calls = calls + 1
const {key, text} = event.detail
assert.equal('[[', key)
receivedText[text] = true
receivedText.push(text)
})
triggerInput(input, '[[')
triggerInput(input, '[[a')
@ -90,10 +88,7 @@ describe('text-expander element', function() {
triggerInput(input, '[[abc')
triggerInput(input, '[[abcd')
for (const text of expectedText) {
assert(receivedText[text], 'expected `${text}`')
}
assert.equal(5, calls)
assert.deepEqual(receivedText, expectedText)
})
})
@ -139,15 +134,13 @@ describe('text-expander element', function() {
const expander = document.querySelector('text-expander')
const input = expander.querySelector('textarea')
let calls = 0
const receivedText = {}
const receivedText = []
const expectedText = ['', 'a', 'ab', 'abc', 'abcd', 'abcd def']
expander.addEventListener('text-expander-change', event => {
calls = calls + 1
const {key, text} = event.detail
assert.equal('[[', key)
receivedText[text] = true
receivedText.push(text)
})
triggerInput(input, '[[')
triggerInput(input, '[[a')
@ -156,10 +149,7 @@ describe('text-expander element', function() {
triggerInput(input, '[[abcd')
triggerInput(input, '[[abcd def')
for (const text of expectedText) {
assert(receivedText[text], 'expected: `${text}`')
}
assert.equal(6, calls)
assert.deepEqual(receivedText, expectedText)
})
it('dispatches change event for single word match after multi-word', async function() {