Skip to content

Commit

Permalink
fix(ref: no-ref): fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andriikamaldinov1 committed Nov 5, 2024
1 parent f371fdb commit 51d5cd5
Show file tree
Hide file tree
Showing 9 changed files with 668 additions and 564 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
https://github.com/JsDaddy/ngx-mask/issues/1372
https://github.com/JsDaddy/ngx-mask/issues/1441
https://github.com/JsDaddy/ngx-mask/issues/1442
https://github.com/JsDaddy/ngx-mask/issues/1440


# 18.0.2(2024-11-01)

Expand Down
5 changes: 3 additions & 2 deletions projects/ngx-mask-lib/src/lib/ngx-mask.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ export class NgxMaskService extends NgxMaskApplierService {
) {
return value;
}
if (String(value).length > 16 && this.separatorLimit.length > 14) {

if (String(value).length > 14 && this.maskExpression.startsWith(MaskExpression.SEPARATOR)) {
return String(value);
}

Expand Down Expand Up @@ -693,7 +694,7 @@ export class NgxMaskService extends NgxMaskApplierService {
if (processedResult === this.decimalMarker) {
return null;
}
if (this.separatorLimit.length > 14) {
if (separatorValue.length > 14) {
return String(separatorValue);
}
return this._checkPrecision(this.maskExpression, separatorValue);
Expand Down
193 changes: 0 additions & 193 deletions projects/ngx-mask-lib/src/test/cursor.cy-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,108 +176,6 @@ describe('Test Date Hh:m0', () => {
.clear();
});

it('Mask separator.2 check cursor with value 100.0', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
decimalMarker: '.',
thousandSeparator: ',',
},
imports: [CypressTestMaskModule],
});
cy.get('#masked')
.type('1000')
.type('{leftArrow}')
.type('.')
.should('have.value', '100.0')
.should('have.prop', 'selectionStart', 4);
});

it('Mask separator.2 check cursor with value 1.00', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
decimalMarker: '.',
thousandSeparator: ',',
},
imports: [CypressTestMaskModule],
});
cy.get('#masked')
.type('1000')
.type('{leftArrow}'.repeat(3))
.type('.')
.should('have.value', '1.00')
.should('have.prop', 'selectionStart', 2);
});

it('Mask separator.2 check cursor with value 123456789.20', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
decimalMarker: '.',
thousandSeparator: ',',
},
imports: [CypressTestMaskModule],
});
cy.get('#masked')
.type('123456789.20')
.type('{leftArrow}'.repeat(4))
.type('.')
.should('have.value', '12,345,678.9')
.should('have.prop', 'selectionStart', 11);
});

it('Mask separator.2 check cursor with value 100.0', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
decimalMarker: ',',
thousandSeparator: '.',
},
imports: [CypressTestMaskModule],
});
cy.get('#masked')
.type('1000')
.type('{leftArrow}')
.type(',')
.should('have.value', '100,0')
.should('have.prop', 'selectionStart', 4);
});

it('Mask separator.2 check cursor with value 1.00', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
decimalMarker: ',',
thousandSeparator: '.',
},
imports: [CypressTestMaskModule],
});
cy.get('#masked')
.type('1000')
.type('{leftArrow}'.repeat(3))
.type(',')
.should('have.value', '1,00')
.should('have.prop', 'selectionStart', 2);
});

it('Mask separator.2 check cursor with value 123456789.20', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
decimalMarker: ',',
thousandSeparator: '.',
},
imports: [CypressTestMaskModule],
});
cy.get('#masked')
.type('123456789,20')
.type('{leftArrow}'.repeat(4))
.type(',')
.should('have.value', '12.345.678,9')
.should('have.prop', 'selectionStart', 11);
});

it('Mask d0/M0/0000 should set cursor on right position', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
Expand Down Expand Up @@ -381,95 +279,4 @@ describe('Test Date Hh:m0', () => {
cy.get('#masked').type('111').should('have.value', '(11) 1');
cy.get('#masked').type('{backspace}').should('have.prop', 'selectionStart', 4);
});

it('when decimalMarker doenst set should have right position cursor thousandSeparator = .', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
thousandSeparator: '.',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('12345678,00')

.should('have.value', '12.345.678,00')
.type('{leftArrow}'.repeat(3))
.type('{backspace}'.repeat(3))
.should('have.value', '12.345,00');
});

it('when decimalMarker doenst set should have right position cursor thousandSeparator = ,', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
thousandSeparator: ',',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('12345678.00')

.should('have.value', '12,345,678.00')
.type('{leftArrow}'.repeat(3))
.type('{backspace}'.repeat(3))
.should('have.value', '12,345.00');
});

it('should place cursor after backspace with separatorLimit = 10 in correct position', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
separatorLimit: '10',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('12.10')
.should('have.value', '12.10')
.type('{leftArrow}'.repeat(2))
.type('{backspace}')
.should('have.value', '12')
.should('have.prop', 'selectionStart', 2);
});

it('should place cursor after backspace with separatorLimit = 100 in correct position', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
separatorLimit: '100',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('123.10')
.should('have.value', '123.10')
.type('{leftArrow}'.repeat(2))
.type('{backspace}')
.should('have.value', '123')
.should('have.prop', 'selectionStart', 3);
});

it('should place cursor after backspace with separatorLimit = 1000 in correct position', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
thousandSeparator: ',',
separatorLimit: '1000',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('1234.10')
.should('have.value', '1,234.10')
.type('{leftArrow}'.repeat(2))
.type('{backspace}')
.should('have.value', '1,234')
.should('have.prop', 'selectionStart', 5);
});
});
Loading

0 comments on commit 51d5cd5

Please sign in to comment.