1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
import { DropdownOpen } from './dropdownopen';
import { Dropdown } from './dropdown';
import { ElementRef, Host, HostListener } from '@angular/core';
import { async, TestBed, inject } from '@angular/core/testing';
describe('DropdownOpen', () => {
let directive;
let dropdown = new Dropdown(new ElementRef(''));
beforeEach(() => {
directive = new DropdownOpen(dropdown, new ElementRef(''));
});
it('should create an instance', () => {
expect(directive).toBeTruthy();
});
describe('should validate on Host click event', () => {
it('should validate openDropdown method if activateOnFocus, openedByFocus are true', () => {
let event = new Event('click');
let dispatchEvent = window.dispatchEvent(event);
dropdown.activateOnFocus = true;
directive.openedByFocus = true;
directive.openDropdown();
});
it('should validate openDropdown method if dropdown.isOpened(), dropdown.toggleClick false', () => {
});
});
it('should validate on Host keydown event', () => {
let spy = spyOn(directive, 'openDropdown')
var event = new KeyboardEvent("keydown");
Object.defineProperty(event, "keyCode", {"value" : 40})
directive.dropdownKeydown(event);
expect(spy).toHaveBeenCalled()
});
it('should validate on Host focus event', () => {
dropdown.activateOnFocus = false;
directive.onFocus();
});
});
|