generated from Tinkoff/angular-open-source-starter
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(demo-integrations): refactored tests for custom minus sign in nu…
…mber
- Loading branch information
Stanslav Zaytsev
committed
Mar 6, 2024
1 parent
ac55a1f
commit b7dac00
Showing
1 changed file
with
38 additions
and
52 deletions.
There are no files selected for viewing
90 changes: 38 additions & 52 deletions
90
projects/demo-integrations/src/tests/kit/number/number-minus-sign.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,45 @@ | ||
import {CHAR_EN_DASH, CHAR_HYPHEN, CHAR_JP_HYPHEN} from 'projects/kit/src/lib/constants'; | ||
import { | ||
CHAR_EM_DASH, | ||
CHAR_EN_DASH, | ||
CHAR_HYPHEN, | ||
CHAR_JP_HYPHEN, | ||
CHAR_MINUS, | ||
} from 'projects/kit/src/lib/constants'; | ||
|
||
import {openNumberPage} from './utils'; | ||
|
||
describe('Properly using custom minus sign', () => { | ||
describe(`correctly applies ${CHAR_HYPHEN} as minus sign`, () => { | ||
beforeEach(() => { | ||
openNumberPage(`minusSign=${CHAR_HYPHEN}&thousandSeparator=_`); | ||
}); | ||
|
||
it(`-32412 => ${CHAR_HYPHEN}32_412`, () => { | ||
cy.get('@input').type('-32412').should('have.value', `${CHAR_HYPHEN}32_412`); | ||
}); | ||
|
||
it(`${CHAR_HYPHEN}32412 => ${CHAR_HYPHEN}32_412`, () => { | ||
cy.get('@input').type('-32412').should('have.value', `${CHAR_HYPHEN}32_412`); | ||
}); | ||
|
||
it(`${CHAR_JP_HYPHEN}32412 => ${CHAR_HYPHEN}32_412`, () => { | ||
cy.get('@input') | ||
.type(`${CHAR_JP_HYPHEN}32412`) | ||
.should('have.value', `${CHAR_HYPHEN}32_412`); | ||
}); | ||
|
||
it(`${CHAR_EN_DASH}32412 => ${CHAR_HYPHEN}32_412`, () => { | ||
cy.get('@input') | ||
.type(`${CHAR_EN_DASH}32412`) | ||
.should('have.value', `${CHAR_HYPHEN}32_412`); | ||
}); | ||
}); | ||
|
||
describe('correctly works with decimal, and minus sign is i', () => { | ||
beforeEach(() => { | ||
openNumberPage('minusSign=i&precision=Infinity&thousandSeparator=_'); | ||
}); | ||
|
||
it('-324,12 => i_324.12', () => { | ||
cy.get('@input').type('-324,12').should('have.value', 'i_324.12'); | ||
}); | ||
|
||
it(`${CHAR_HYPHEN}324,12 => i_324.12`, () => { | ||
cy.get('@input') | ||
.type(`${CHAR_HYPHEN}324,12`) | ||
.should('have.value', 'i_324.12'); | ||
}); | ||
|
||
it(`${CHAR_JP_HYPHEN}324,12 => i_324.12`, () => { | ||
cy.get('@input') | ||
.type(`${CHAR_JP_HYPHEN}324,12`) | ||
.should('have.value', 'i_324.12'); | ||
}); | ||
|
||
it(`${CHAR_EN_DASH}324,12 => i_324.12`, () => { | ||
cy.get('@input') | ||
.type(`${CHAR_EN_DASH}324,12`) | ||
.should('have.value', 'i_324.12'); | ||
const minuses: Array<{value: string; name: string; asQueryParam: string}> = [ | ||
{value: CHAR_HYPHEN, name: 'hyphen', asQueryParam: '-'}, | ||
{value: 'i', name: 'i', asQueryParam: 'i'}, | ||
]; | ||
|
||
const numbers = ['321', '2_432']; | ||
|
||
const pseudoMinuses: Array<{value: string; name: string}> = [ | ||
{value: CHAR_HYPHEN, name: 'hyphen'}, | ||
{value: CHAR_EN_DASH, name: 'en-dash'}, | ||
{value: CHAR_EM_DASH, name: 'em-dash'}, | ||
{value: CHAR_JP_HYPHEN, name: 'japanese prolonged sound mark'}, | ||
{value: CHAR_MINUS, name: 'unicode minus sign'}, | ||
]; | ||
|
||
minuses.forEach(minus => { | ||
if (minus.value === 'i') { | ||
pseudoMinuses.push(minus); | ||
} | ||
|
||
pseudoMinuses.forEach(pseudoMinus => { | ||
numbers.forEach(number => { | ||
it(`transforms ${pseudoMinus.name} into ${minus.name}`, () => { | ||
openNumberPage( | ||
`precision=Infinity&thousandSeparator=_&minusSign=${minus.asQueryParam}`, | ||
); | ||
cy.get('@input') | ||
.type(`${pseudoMinus.value}${number}`) | ||
.should('have.value', `${minus.value}${number}`); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |