|
| 1 | +import {browser, by, element} from 'protractor'; |
| 2 | + |
| 3 | +describe('input', () => { |
| 4 | + |
| 5 | + beforeEach(async () => await browser.get('/mdc-input')); |
| 6 | + |
| 7 | + describe('text input', () => { |
| 8 | + |
| 9 | + it('should update input value when user types', async () => { |
| 10 | + const input = element(by.id('text-input')); |
| 11 | + await input.sendKeys('abc123'); |
| 12 | + expect(await input.getAttribute('value')).toBe('abc123'); |
| 13 | + }); |
| 14 | + }); |
| 15 | + |
| 16 | + describe('number input', () => { |
| 17 | + |
| 18 | + it('should update input value when user types', async () => { |
| 19 | + const input = element(by.id('number-input')); |
| 20 | + await input.sendKeys('abc123'); |
| 21 | + expect(await input.getAttribute('value')).toBe('123'); |
| 22 | + }); |
| 23 | + |
| 24 | + it('should increment when increment button clicked', async () => { |
| 25 | + const input = element(by.id('number-input')); |
| 26 | + await input.click(); |
| 27 | + |
| 28 | + const size = await input.getSize(); |
| 29 | + |
| 30 | + await browser.actions() |
| 31 | + .mouseMove(input, {x: size.width - 5, y: 5}) |
| 32 | + .perform(); |
| 33 | + // Workaround: https://github.com/angular/protractor/issues/4578 |
| 34 | + await browser.actions().click().perform(); |
| 35 | + |
| 36 | + expect(await input.getAttribute('value')).toBe('1'); |
| 37 | + |
| 38 | + await browser.actions() |
| 39 | + .mouseMove(input, {x: size.width - 5, y: size.height - 5}) |
| 40 | + .perform(); |
| 41 | + // Workaround: https://github.com/angular/protractor/issues/4578 |
| 42 | + await browser.actions().click().perform(); |
| 43 | + |
| 44 | + expect(await input.getAttribute('value')).toBe('0'); |
| 45 | + }); |
| 46 | + }); |
| 47 | + |
| 48 | + describe('textarea', () => { |
| 49 | + |
| 50 | + it('should update input value when user types', async () => { |
| 51 | + const input = element(by.id('text-area')); |
| 52 | + await input.sendKeys('abc123'); |
| 53 | + expect(await input.getAttribute('value')).toBe('abc123'); |
| 54 | + }); |
| 55 | + }); |
| 56 | + |
| 57 | + describe('autosize-textarea', () => { |
| 58 | + |
| 59 | + it('should resize correctly', async () => { |
| 60 | + const input = element(by.id('autosize-text-area')); |
| 61 | + await input.sendKeys('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); |
| 62 | + }); |
| 63 | + |
| 64 | + it('should enfore max rows', async () => { |
| 65 | + const input = element(by.id('autosize-text-area')); |
| 66 | + await input.sendKeys( |
| 67 | + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + |
| 68 | + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + |
| 69 | + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + |
| 70 | + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); |
| 71 | + }); |
| 72 | + }); |
| 73 | +}); |
0 commit comments