-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test cases for mentions, range and textarea; fix type issue…
…s, fix workflow issue
- Loading branch information
Showing
12 changed files
with
74 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const options = [ | ||
{ label: 'option1', value: 'value1' }, | ||
{ label: 'option2', value: 'value2', disabled: true }, | ||
{ label: 'option3', value: 'value3' }, | ||
{ label: 'option4', value: 'value4' }, | ||
{ label: 'option5', value: 'value5' }, | ||
]; | ||
|
||
describe('Mentions', () => { | ||
it('should render correctly', async () => { | ||
const ce = l('l-mentions', { | ||
value: 'test@value1 @value4 what', | ||
options, | ||
}), | ||
root = ce.shadowRoot!; | ||
const edit = root.querySelector('[contenteditable]')!; | ||
expect(edit).not.toBeNull(); | ||
expect(edit.children[0].textContent).toBe('test'); | ||
// at the beginning, edit.children[1].textContent is value1 // TODO check what delay this | ||
await vi.waitFor(() => expect(edit.children[1].textContent).toBe('option1')); | ||
expect(edit.children[2].textContent).toBe(''); | ||
expect(edit.children[3].textContent).toBe('option4'); | ||
expect(edit.children[4].textContent).toBe('what'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
describe('Range', () => { | ||
it('should render correctly', () => { | ||
const ce = l('l-range', { | ||
value: 30, | ||
}), | ||
root = ce.shadowRoot!; | ||
const first = root.firstElementChild as HTMLElement; | ||
expect(first.style.getPropertyValue('--l-range-min')).toBe('0'); | ||
expect(first.style.getPropertyValue('--l-range-max')).toBe('0.3'); | ||
const thumb = root.querySelector('.l-range__thumb') as HTMLElement; | ||
expect(thumb.style.getPropertyValue('--l-range-percent')).toBe('0.3'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { userEvent } from '@vitest/browser/context'; | ||
|
||
describe('Textarea', () => { | ||
it('type in textarea', async () => { | ||
let value = ''; | ||
const onUpdate = vi.fn((e: any) => { | ||
value = e.detail; | ||
}); | ||
const handlers = { | ||
onUpdate, | ||
}; | ||
const ce = l('l-textarea', handlers); | ||
ce.focus(); | ||
expect(ce.textarea?.tagName).to.equal('TEXTAREA'); | ||
expect(ce.textarea.matches(':focus')).to.be.true; | ||
await userEvent.type(ce.textarea, 'Hello'); | ||
expect(value).to.equal('Hello'); | ||
expect(onUpdate).toHaveBeenCalledTimes(5); | ||
}); | ||
}); |
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
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