|
1 |
| -import { Autocomplete, AutocompleteStatus } from '../src/index'; |
| 1 | +'use strict'; |
| 2 | + |
| 3 | +import { initialiseEnvironment } from './initialiseEnvironment'; |
2 | 4 |
|
3 | 5 | jest.useFakeTimers();
|
4 | 6 |
|
5 | 7 | describe('Mouseover Tests', () => {
|
6 |
| - let inputEL: HTMLInputElement, autocomplete: Autocomplete; |
7 |
| - |
8 |
| - describe('Test environment:-', () => { |
9 |
| - it('has added element', () => { |
10 |
| - inputEL = document.createElement('input'); |
11 |
| - |
12 |
| - inputEL.classList.add('test'); |
13 |
| - inputEL = document.body.insertAdjacentElement( |
14 |
| - 'beforeend', |
15 |
| - inputEL, |
16 |
| - ) as HTMLInputElement; |
17 |
| - |
18 |
| - expect(inputEL).not.toBeNull(); |
19 |
| - }); |
20 |
| - |
21 |
| - it('has created autocomplete', () => { |
22 |
| - autocomplete = new Autocomplete('.test', { |
23 |
| - source: [ |
24 |
| - { label: 'First label', value: 'First Value' }, |
25 |
| - { label: 'Second label', value: 'Second Value' }, |
26 |
| - { label: 'Third label', value: 'Third Value' }, |
27 |
| - { label: 'Final label', value: 'Final Value' }, |
28 |
| - ], |
29 |
| - onOpen: (e, data) => { |
30 |
| - data.ul.style.width = `${ |
31 |
| - (e.target as HTMLInputElement).width |
32 |
| - }px`; |
33 |
| - }, |
34 |
| - }); |
35 |
| - |
36 |
| - expect(autocomplete).not.toBeNull(); |
37 |
| - }); |
38 |
| - |
39 |
| - it('has initial state of "stopped"', () => |
40 |
| - expect(autocomplete.status).toBe(AutocompleteStatus.Stopped)); |
41 |
| - |
42 |
| - it('"start" should not throw', () => |
43 |
| - expect(autocomplete.start).not.toThrow()); |
44 |
| - |
45 |
| - it('now has "started" state', () => |
46 |
| - expect(autocomplete.status).toBe(AutocompleteStatus.Started)); |
47 |
| - }); |
| 8 | + const { inputEL, autocomplete } = initialiseEnvironment(); |
48 | 9 |
|
49 | 10 | describe('Mouse over', () => {
|
50 | 11 | beforeEach(() => {
|
|
0 commit comments