|
| 1 | +/* global describe, beforeEach, it */ |
| 2 | +import { expect } from 'chai'; |
| 3 | +import { useFixture } from '../helpers'; |
| 4 | +import { interactor, isFocused } from '../../src'; |
| 5 | + |
| 6 | +@interactor class FocusedInteractor { |
| 7 | + isEmailFocused = isFocused('#email'); |
| 8 | + isPasswordFocused = isFocused('#password'); |
| 9 | +} |
| 10 | + |
| 11 | +describe('BigTest Interaction: isFocused', () => { |
| 12 | + let test; |
| 13 | + |
| 14 | + useFixture('is-focused-fixture'); |
| 15 | + |
| 16 | + beforeEach(() => { |
| 17 | + test = new FocusedInteractor('#focus-form'); |
| 18 | + }); |
| 19 | + |
| 20 | + it('has isFocused properties', () => { |
| 21 | + expect(test).to.have.property('isFocused').that.is.a('boolean'); |
| 22 | + expect(test).to.have.property('isEmailFocused').that.is.a('boolean'); |
| 23 | + expect(test).to.have.property('isPasswordFocused').that.is.a('boolean'); |
| 24 | + }); |
| 25 | + |
| 26 | + it('returns true if the element is focused', () => { |
| 27 | + expect(test.isFocused).to.be.false; |
| 28 | + expect(test.isEmailFocused).to.be.true; |
| 29 | + expect(test.isPasswordFocused).to.be.true; |
| 30 | + }); |
| 31 | + |
| 32 | + it('returns false if the element is not focused', () => { |
| 33 | + test.focus('#password'); |
| 34 | + expect(test.isFocused).to.be.false; |
| 35 | + expect(test.isEmailFocused).to.be.false; |
| 36 | + expect(test.isPasswordFocused).to.be.true; |
| 37 | + }); |
| 38 | +}); |
0 commit comments