mirror of
https://github.com/tenrok/maska.git
synced 2026-06-17 19:21:21 +03:00
+1
-1
@@ -11,7 +11,7 @@ const createFormatter = (min: number, max: number, opts: MaskOptions): Intl.Numb
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const processNumber = (value: string, masked = true, opts: MaskOptions): string => {
|
export const processNumber = (value: string, masked = true, opts: MaskOptions): string => {
|
||||||
const sign = opts.number?.unsigned == null && value.startsWith('-') ? '-' : ''
|
const sign = opts.number?.unsigned !== true && value.startsWith('-') ? '-' : ''
|
||||||
const fraction = opts.number?.fraction ?? 0
|
const fraction = opts.number?.fraction ?? 0
|
||||||
|
|
||||||
let formatter = createFormatter(0, fraction, opts)
|
let formatter = createFormatter(0, fraction, opts)
|
||||||
|
|||||||
@@ -88,6 +88,14 @@ test('unsigned number', () => {
|
|||||||
expect(mask.masked('--1')).toBe('1')
|
expect(mask.masked('--1')).toBe('1')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('unsigned false number', () => {
|
||||||
|
const mask = new Mask({ number: { unsigned: false } })
|
||||||
|
|
||||||
|
expect(mask.masked('1')).toBe('1')
|
||||||
|
expect(mask.masked('-1')).toBe('-1')
|
||||||
|
expect(mask.masked('--1')).toBe('-1')
|
||||||
|
})
|
||||||
|
|
||||||
test('russian number', () => {
|
test('russian number', () => {
|
||||||
const mask = new Mask({ number: { locale: 'ru', fraction: 2 } })
|
const mask = new Mask({ number: { locale: 'ru', fraction: 2 } })
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user