|
| 1 | +import {DemoPath} from '@demo/constants'; |
| 2 | + |
| 3 | +describe('Phone [strict]=true', () => { |
| 4 | + describe('[countryIsoCode]=KZ', () => { |
| 5 | + beforeEach(() => { |
| 6 | + cy.visit(`/${DemoPath.PhonePackage}/API?countryIsoCode=KZ&strict=true`); |
| 7 | + cy.get('#demo-content input') |
| 8 | + .should('be.visible') |
| 9 | + .first() |
| 10 | + .focus() |
| 11 | + .should('have.value', '+7 ') |
| 12 | + .as('input'); |
| 13 | + }); |
| 14 | + |
| 15 | + it('Paste +7 777 (+7 is treated as country prefix => no prefix duplication)', () => { |
| 16 | + cy.get('@input') |
| 17 | + .paste('+7 777') |
| 18 | + .should('have.value', '+7 777') |
| 19 | + .should('have.prop', 'selectionStart', '+7 777'.length) |
| 20 | + .should('have.prop', 'selectionEnd', '+7 777'.length); |
| 21 | + }); |
| 22 | + |
| 23 | + it('Paste +7777 (+7 is treated as country prefix => no prefix duplication)', () => { |
| 24 | + cy.get('@input') |
| 25 | + .paste('+7777') |
| 26 | + .should('have.value', '+7 777') |
| 27 | + .should('have.prop', 'selectionStart', '+7 777'.length) |
| 28 | + .should('have.prop', 'selectionEnd', '+7 777'.length); |
| 29 | + }); |
| 30 | + |
| 31 | + it('Paste 7777 (no plus sign => all 4 sevens are treated as of incomplete value (+7 is added automatically))', () => { |
| 32 | + cy.get('@input') |
| 33 | + .paste('7777') |
| 34 | + .should('have.value', '+7 777 7') |
| 35 | + .should('have.prop', 'selectionStart', '+7 777 7'.length) |
| 36 | + .should('have.prop', 'selectionEnd', '+7 777 7'.length); |
| 37 | + }); |
| 38 | + }); |
| 39 | + |
| 40 | + describe('[countryIsoCode]=RU', () => { |
| 41 | + beforeEach(() => { |
| 42 | + cy.visit(`/${DemoPath.PhonePackage}/API?countryIsoCode=RU&strict=true`); |
| 43 | + cy.get('#demo-content input') |
| 44 | + .should('be.visible') |
| 45 | + .first() |
| 46 | + .focus() |
| 47 | + .should('have.value', '+7 ') |
| 48 | + .as('input'); |
| 49 | + }); |
| 50 | + |
| 51 | + [ |
| 52 | + '+7 912 345-67-89', |
| 53 | + '+79123456789', |
| 54 | + '79123456789', // even without plus sign => no country prefix duplication |
| 55 | + '89123456789', // 8 should be replaced by +7 automatically |
| 56 | + '9123456789', |
| 57 | + ].forEach((value) => { |
| 58 | + it(`Paste ${value}`, () => { |
| 59 | + cy.get('@input') |
| 60 | + .paste(value) |
| 61 | + .should('have.value', '+7 912 345-67-89') |
| 62 | + .should('have.prop', 'selectionStart', '+7 912 345-67-89'.length) |
| 63 | + .should('have.prop', 'selectionEnd', '+7 912 345-67-89'.length); |
| 64 | + }); |
| 65 | + }); |
| 66 | + }); |
| 67 | +}); |
0 commit comments