Skip to content

Commit

Permalink
Updating test
Browse files Browse the repository at this point in the history
  • Loading branch information
hutchgrant committed Jan 7, 2019
1 parent 2372bef commit 643d943
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/components/dropdown/dropdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe('Dropdown Component', () => {
});

afterEach(() => {
dropdown.remove();
dropdown = null;
// dropdown.remove();
// dropdown = null;
});

it('should have one default element', () => {
Expand Down Expand Up @@ -77,47 +77,47 @@ describe('Dropdown Component', () => {
});

it('should add a click event listener', () => {
let button = dropdown.shadowRoot.querySelector('.dropdown-el');
let spyEvent = spyOn(button, 'click');
const button = dropdown.shadowRoot.querySelector('.dropdown-el');
const spyEvent = spyOn(button, 'click');

button.click();

expect(spyEvent).toHaveBeenCalled();
});

it('should expand on click', () => {
let button = dropdown.shadowRoot.querySelector('.dropdown-el');
const button = dropdown.shadowRoot.querySelector('.dropdown-el');

button.click();
expect(button).toHaveClass('expanded');
});

it('should collapse after an item is clicked', () => {
let button = dropdown.shadowRoot.querySelector('.dropdown-el');
const button = dropdown.shadowRoot.querySelector('.dropdown-el');

button.click();
let selection = button.querySelector('[for="option_0"]');
const selection = button.querySelector('[for="option_0"]');

selection.click();

expect(button).not.toHaveClass('expanded');
});

it('should display selected item as default option', () => {
let button = dropdown.shadowRoot.querySelector('.dropdown-el');
const button = dropdown.shadowRoot.querySelector('.dropdown-el');

button.click();
let selection = button.querySelector('[for="option_0"]');
const selection = button.querySelector('[for="option_0"]');

selection.click();

let defaultOption = button.querySelector('[for="option_def"]').textContent;
const defaultOption = button.querySelector('[for="option_def"]').textContent;

expect(defaultOption).toEqual(options[0].label);
});

it('should collapse on click anywhere else in the window', () => {
let button = dropdown.shadowRoot.querySelector('.dropdown-el');
const button = dropdown.shadowRoot.querySelector('.dropdown-el');

button.click();

Expand Down

0 comments on commit 643d943

Please sign in to comment.