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

feat(tests): update few tests to improve coverage #201

Merged
merged 2 commits into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ describe('the Decimal Formatter', () => {
expect(output).toBe('99.10');
});

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

it('should display a number with dollar sign and use "maxDecimal" params', () => {
Expand Down
11 changes: 1 addition & 10 deletions src/app/modules/angular-slickgrid/formatters/maskFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,7 @@ export const maskFormatter: Formatter = (row: number, cell: number, value: any,
if (value) {
let i = 0;
const v = value.toString();
return mask.replace(/[09A]/gi, (match: string) => {
// 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
if (
((match === '0' || match === '9') && /\d*/g.test(v[i])) // mask is 0 or 9 and value is a digit
|| (match.toUpperCase() === 'A' && /[^\d]*/gi.test(v[i])) // OR mask is an "A" and value is non-digit
) {
return v[i++] || '';
}
return '';
});
return mask.replace(/[09A]/gi, () => v[i++] || '');
}
return value;
};
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const extensionHeaderMenuStub = {
translateHeaderMenu: jest.fn()
};

describe('GridStateService', () => {
describe('ExtensionService', () => {
let service: ExtensionService;
let translate: TranslateService;

Expand Down