Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit ebf3d2f

Browse files
authored
Merge pull request #201 from ghiscoding/feat/test-extension-service
feat(tests): update few tests to improve coverage
2 parents 3af5a3a + 522277c commit ebf3d2f

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

src/app/modules/angular-slickgrid/formatters/__tests__/decimalFormatter.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ describe('the Decimal Formatter', () => {
4646
expect(output).toBe('99.10');
4747
});
4848

49-
it('should display a number with dollar sign and use "minDecimalPlaces" params', () => {
49+
it('should display a number with dollar sign and use "minDecimalPlaces" (or the deprecated "decimalPlaces") params', () => {
5050
const input = 99.1;
51-
const output = decimalFormatter(1, 1, input, { params: { minDecimalPlaces: 2 } } as Column, {});
52-
expect(output).toBe('99.10');
51+
const output1 = decimalFormatter(1, 1, input, { params: { minDecimalPlaces: 2 } } as Column, {});
52+
const output2 = decimalFormatter(1, 1, input, { params: { decimalPlaces: 2 } } as Column, {});
53+
expect(output1).toBe('99.10');
54+
expect(output2).toBe('99.10');
5355
});
5456

5557
it('should display a number with dollar sign and use "maxDecimal" params', () => {

src/app/modules/angular-slickgrid/formatters/maskFormatter.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,7 @@ export const maskFormatter: Formatter = (row: number, cell: number, value: any,
1616
if (value) {
1717
let i = 0;
1818
const v = value.toString();
19-
return mask.replace(/[09A]/gi, (match: string) => {
20-
// only replace the char when the mask is a 0 or 9 for a digit OR the mask is "A" and the char is a non-digit meaning a string char
21-
if (
22-
((match === '0' || match === '9') && /\d*/g.test(v[i])) // mask is 0 or 9 and value is a digit
23-
|| (match.toUpperCase() === 'A' && /[^\d]*/gi.test(v[i])) // OR mask is an "A" and value is non-digit
24-
) {
25-
return v[i++] || '';
26-
}
27-
return '';
28-
});
19+
return mask.replace(/[09A]/gi, () => v[i++] || '');
2920
}
3021
return value;
3122
};

src/app/modules/angular-slickgrid/services/__tests__/extension.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const extensionHeaderMenuStub = {
5656
translateHeaderMenu: jest.fn()
5757
};
5858

59-
describe('GridStateService', () => {
59+
describe('ExtensionService', () => {
6060
let service: ExtensionService;
6161
let translate: TranslateService;
6262

0 commit comments

Comments
 (0)