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

Commit e609ad3

Browse files
authored
Merge pull request #640 from ghiscoding/bugfix/date-us-format
fix(formatters): date US Formatters should accept ISO date input
2 parents dd76dd7 + 482d0f5 commit e609ad3

File tree

61 files changed

+595
-517
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+595
-517
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ import { alignRightFormatter } from '../alignRightFormatter';
33

44
describe('Right Alignment Formatter', () => {
55
it('should return an empty string when no value is passed', () => {
6-
const output = alignRightFormatter(1, 1, '', {} as Column, {});
6+
const output = alignRightFormatter(1, 1, '', {} as Column, {}, {});
77
expect(output).toBe('<div style="float: right"></div>');
88
});
99

1010
it('should return an empty string when value is null or undefined', () => {
11-
const output1 = alignRightFormatter(1, 1, null, {} as Column, {});
12-
const output2 = alignRightFormatter(1, 1, undefined, {} as Column, {});
11+
const output1 = alignRightFormatter(1, 1, null, {} as Column, {}, {});
12+
const output2 = alignRightFormatter(1, 1, undefined, {} as Column, {}, {});
1313

1414
expect(output1).toBe('<div style="float: right"></div>');
1515
expect(output2).toBe('<div style="float: right"></div>');
1616
});
1717

1818
it('should return a string all in uppercase', () => {
19-
const output = alignRightFormatter(1, 1, 'hello', {} as Column, {});
19+
const output = alignRightFormatter(1, 1, 'hello', {} as Column, {}, {});
2020
expect(output).toBe('<div style="float: right">hello</div>');
2121
});
2222

2323
it('should return a number as a string', () => {
24-
const output = alignRightFormatter(1, 1, 99, {} as Column, {});
24+
const output = alignRightFormatter(1, 1, 99, {} as Column, {}, {});
2525
expect(output).toBe('<div style="float: right">99</div>');
2626
});
2727

2828
it('should return a boolean as a string all in uppercase', () => {
29-
const output = alignRightFormatter(1, 1, false, {} as Column, {});
29+
const output = alignRightFormatter(1, 1, false, {} as Column, {}, {});
3030
expect(output).toBe('<div style="float: right">false</div>');
3131
});
3232
});

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,41 @@ describe('the ArrayObjectToCsv Formatter', () => {
1111
];
1212

1313
it('should throw an error when omitting to pass "propertyNames" to "params"', () => {
14-
expect(() => arrayObjectToCsvFormatter(0, 0, 'anything', {} as Column, {}))
14+
expect(() => arrayObjectToCsvFormatter(0, 0, 'anything', {} as Column, {}, {}))
1515
.toThrowError('Formatters.arrayObjectToCsv requires you to pass an array of "propertyNames"');
1616
});
1717

1818
it('should return original input value when the "propertyNames" is not found in the given object', () => {
1919
const params = { propertyNames: ['name'] };
20-
const result = arrayObjectToCsvFormatter(0, 0, 'anything', { field: 'roles', params } as Column, {});
20+
const result = arrayObjectToCsvFormatter(0, 0, 'anything', { field: 'roles', params } as Column, {}, {});
2121
expect(result).toBe('anything');
2222
});
2323

2424
it('should return original input value when the "propertyNames" is found to be holding an empty array', () => {
2525
const params = { propertyNames: ['name'] };
26-
const result = arrayObjectToCsvFormatter(0, 0, 'anything', { field: 'roles', params } as Column, dataset[2]);
26+
const result = arrayObjectToCsvFormatter(0, 0, 'anything', { field: 'roles', params } as Column, dataset[2], {});
2727
expect(result).toBe('anything');
2828
});
2929

3030
it('should return csv string in a span (with it\'s content and title attribute to be the same) when multiple input values are passed', () => {
3131
const params = { propertyNames: ['name'] };
3232
const expectedOutput = 'Administrator, Regular User';
33-
const result = arrayObjectToCsvFormatter(0, 0, 'anything', { field: 'roles', params } as Column, dataset[0]);
33+
const result = arrayObjectToCsvFormatter(0, 0, 'anything', { field: 'roles', params } as Column, dataset[0], {});
3434
expect(result).toBe(`<span title="${expectedOutput}">${expectedOutput}</span>`);
3535
});
3636

3737
it('should return regular string in a span (with it\'s content and title attribute to be the same) when 1 input value is passed', () => {
3838
const params = { propertyNames: ['name'] };
3939
const expectedOutput = 'Regular User';
40-
const result = arrayObjectToCsvFormatter(0, 0, 'anything', { field: 'roles', params } as Column, dataset[1]);
40+
const result = arrayObjectToCsvFormatter(0, 0, 'anything', { field: 'roles', params } as Column, dataset[1], {});
4141
expect(result).toBe(`<span title="${expectedOutput}">${expectedOutput}</span>`);
4242
});
4343

4444
it(`should return csv string in a span when multiple input values are passed
4545
and user provide a different "dataContextProperty" to pull the data from a different field of the dataContext object`, () => {
46-
const params = { dataContextProperty: 'roles', propertyNames: ['name'] };
47-
const expectedOutput = 'Administrator, Regular User';
48-
const result = arrayObjectToCsvFormatter(0, 0, 'anything', { field: 'email', params } as Column, dataset[0]);
49-
expect(result).toBe(`<span title="${expectedOutput}">${expectedOutput}</span>`);
50-
});
46+
const params = { dataContextProperty: 'roles', propertyNames: ['name'] };
47+
const expectedOutput = 'Administrator, Regular User';
48+
const result = arrayObjectToCsvFormatter(0, 0, 'anything', { field: 'email', params } as Column, dataset[0], {});
49+
expect(result).toBe(`<span title="${expectedOutput}">${expectedOutput}</span>`);
50+
});
5151
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ import { arrayToCsvFormatter } from '../arrayToCsvFormatter';
44
describe('the ArrayToCsv Formatter', () => {
55
it('should return same output when no value is passed', () => {
66
const valueArray = null;
7-
const result = arrayToCsvFormatter(0, 0, valueArray, {} as Column, {});
7+
const result = arrayToCsvFormatter(0, 0, valueArray, {} as Column, {}, {});
88
expect(result).toBe(null);
99
});
1010

1111
it('should return an empty array when value passed is an empty array', () => {
1212
const valueArray = [];
13-
const result = arrayToCsvFormatter(0, 0, valueArray, {} as Column, {});
13+
const result = arrayToCsvFormatter(0, 0, valueArray, {} as Column, {}, {});
1414
expect(result).toEqual([]);
1515
});
1616

1717
it('should return original value when input is not an array', () => {
1818
const inputValue = 'anything';
19-
const result = arrayToCsvFormatter(0, 0, inputValue, {} as Column, {});
19+
const result = arrayToCsvFormatter(0, 0, inputValue, {} as Column, {}, {});
2020
expect(result).toBe(inputValue);
2121
});
2222

2323
it('should return a CSV string when value passed is an array of string', () => {
2424
const valueArray = ['john', 'doe'];
25-
const result = arrayToCsvFormatter(0, 0, valueArray, {} as Column, {});
25+
const result = arrayToCsvFormatter(0, 0, valueArray, {} as Column, {}, {});
2626
expect(result).toBe(`<span title="${valueArray.join(', ')}">${valueArray.join(', ')}</span>`);
2727
});
2828
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { boldFormatter } from '../boldFormatter';
44
describe('the Bold Formatter', () => {
55
it('should return an empty string when no value is passed', () => {
66
const value = null;
7-
const result = boldFormatter(0, 0, value, {} as Column, {});
7+
const result = boldFormatter(0, 0, value, {} as Column, {}, {});
88
expect(result).toBe('');
99
});
1010

1111
it('should return a bold html formatted string when value is filled', () => {
1212
const value = 'john';
13-
const result = boldFormatter(0, 0, value, {} as Column, {});
13+
const result = boldFormatter(0, 0, value, {} as Column, {}, {});
1414
expect(result).toBe(`<b>${value}</b>`);
1515
});
1616
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { bsDropdownFormatter } from '../bsDropdownFormatter';
33

44
describe('the Bootstrap dropdown Formatter', () => {
55
it('should throw an error when omitting to pass "propertyNames" to "params"', () => {
6-
expect(() => bsDropdownFormatter(0, 0, 'anything', {} as Column, {}))
6+
expect(() => bsDropdownFormatter(0, 0, 'anything', {} as Column, {}, {}))
77
.toThrowError('You must provide the "label" or "formatterLabel" via the generic "params"');
88
});
99

@@ -12,7 +12,7 @@ describe('the Bootstrap dropdown Formatter', () => {
1212
const label = 'Action';
1313
const row = 0;
1414
const cell = 0;
15-
const result = bsDropdownFormatter(row, cell, input, { field: 'user', params: { label } } as Column, {});
15+
const result = bsDropdownFormatter(row, cell, input, { field: 'user', params: { label } } as Column, {}, {});
1616

1717
expect(result).toBe(`<div id="myDrop-r${row}-c${cell}" class="dropdown pointer">
1818
<a class="dropdown-toggle">
@@ -28,7 +28,7 @@ describe('the Bootstrap dropdown Formatter', () => {
2828
const label = 'Action';
2929
const row = 0;
3030
const cell = 0;
31-
const result = bsDropdownFormatter(row, cell, input, { field: 'user', params: { label } } as Column, {});
31+
const result = bsDropdownFormatter(row, cell, input, { field: 'user', params: { label } } as Column, {}, {});
3232

3333
expect(result).toBe(`<div id="myDrop-r${row}-c${cell}" class="dropdown pointer">
3434
<a class="dropdown-toggle">

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@ import { centerFormatter } from '../centerFormatter';
33

44
describe('Center Alignment Formatter', () => {
55
it('should return an empty string when no value is passed', () => {
6-
const output = centerFormatter(1, 1, '', {} as Column, {});
6+
const output = centerFormatter(1, 1, '', {} as Column, {}, {});
77
expect(output).toBe('<center></center>');
88
});
99

1010
it('should return an empty string when value is null or undefined', () => {
11-
const output1 = centerFormatter(1, 1, null, {} as Column, {});
12-
const output2 = centerFormatter(1, 1, undefined, {} as Column, {});
11+
const output1 = centerFormatter(1, 1, null, {} as Column, {}, {});
12+
const output2 = centerFormatter(1, 1, undefined, {} as Column, {}, {});
1313

1414
expect(output1).toBe('<center></center>');
1515
expect(output2).toBe('<center></center>');
1616
});
1717

1818

1919
it('should return a string all in uppercase', () => {
20-
const output = centerFormatter(1, 1, 'hello', {} as Column, {});
20+
const output = centerFormatter(1, 1, 'hello', {} as Column, {}, {});
2121
expect(output).toBe('<center>hello</center>');
2222
});
2323

2424
it('should return a number as a string', () => {
25-
const output = centerFormatter(1, 1, 99, {} as Column, {});
25+
const output = centerFormatter(1, 1, 99, {} as Column, {}, {});
2626
expect(output).toBe('<center>99</center>');
2727
});
2828

2929
it('should return a boolean as a string all in uppercase', () => {
30-
const output = centerFormatter(1, 1, false, {} as Column, {});
30+
const output = centerFormatter(1, 1, false, {} as Column, {}, {});
3131
expect(output).toBe('<center>false</center>');
3232
});
3333
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ import { checkboxFormatter } from '../checkboxFormatter';
44
describe('the Checkbox Formatter', () => {
55
it('should return an empty string when no value is passed', () => {
66
const value = null;
7-
const result = checkboxFormatter(0, 0, value, {} as Column, {});
7+
const result = checkboxFormatter(0, 0, value, {} as Column, {}, {});
88
expect(result).toBe('');
99
});
1010

1111
it('should return an empty string when False is provided', () => {
1212
const value = false;
13-
const result = checkboxFormatter(0, 0, value, {} as Column, {});
13+
const result = checkboxFormatter(0, 0, value, {} as Column, {}, {});
1414
expect(result).toBe('');
1515
});
1616

1717
it('should return the unicode value of a checkbox when input is True', () => {
1818
const value = true;
19-
const result = checkboxFormatter(0, 0, value, {} as Column, {});
19+
const result = checkboxFormatter(0, 0, value, {} as Column, {}, {});
2020
expect(result).toBe('&#x2611;');
2121
});
2222

2323
it('should return the unicode value of a checkbox when input is filled with any string', () => {
2424
const value = 'anything';
25-
const result = checkboxFormatter(0, 0, value, {} as Column, {});
25+
const result = checkboxFormatter(0, 0, value, {} as Column, {}, {});
2626
expect(result).toBe('&#x2611;');
2727
});
2828
});

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,94 +4,94 @@ import { checkmarkFormatter } from '../checkmarkFormatter';
44
describe('the Checkmark Formatter', () => {
55
it('should return an empty string when no value is passed', () => {
66
const value = null;
7-
const result = checkmarkFormatter(0, 0, value, {} as Column, {});
7+
const result = checkmarkFormatter(0, 0, value, {} as Column, {}, {});
88
expect(result).toBe('');
99
});
1010

1111
it('should return an empty string when False is provided', () => {
1212
const value = false;
13-
const result = checkmarkFormatter(0, 0, value, {} as Column, {});
13+
const result = checkmarkFormatter(0, 0, value, {} as Column, {}, {});
1414
expect(result).toBe('');
1515
});
1616

1717
it('should return an empty string when the string "FALSE" (case insensitive) is provided', () => {
1818
const value = 'FALSE';
19-
const result1 = checkmarkFormatter(0, 0, value.toLowerCase(), {} as Column, {});
20-
const result2 = checkmarkFormatter(0, 0, value.toUpperCase(), {} as Column, {});
19+
const result1 = checkmarkFormatter(0, 0, value.toLowerCase(), {} as Column, {}, {});
20+
const result2 = checkmarkFormatter(0, 0, value.toUpperCase(), {} as Column, {}, {});
2121
expect(result1).toBe('');
2222
expect(result2).toBe('');
2323
});
2424

2525
it('should return the Font Awesome Checkmark icon when the string "True" (case insensitive) is provided', () => {
2626
const value = 'True';
27-
const result1 = checkmarkFormatter(0, 0, value.toLowerCase(), {} as Column, {});
28-
const result2 = checkmarkFormatter(0, 0, value.toUpperCase(), {} as Column, {});
27+
const result1 = checkmarkFormatter(0, 0, value.toLowerCase(), {} as Column, {}, {});
28+
const result2 = checkmarkFormatter(0, 0, value.toUpperCase(), {} as Column, {}, {});
2929
expect(result1).toBe('<i class="fa fa-check checkmark-icon" aria-hidden="true"></i>');
3030
expect(result2).toBe('<i class="fa fa-check checkmark-icon" aria-hidden="true"></i>');
3131
});
3232

3333
it('should return the Font Awesome Checkmark icon when input is True', () => {
3434
const value = true;
35-
const result = checkmarkFormatter(0, 0, value, {} as Column, {});
35+
const result = checkmarkFormatter(0, 0, value, {} as Column, {}, {});
3636
expect(result).toBe('<i class="fa fa-check checkmark-icon" aria-hidden="true"></i>');
3737
});
3838

3939
it('should return the Font Awesome Checkmark icon when input is a string even if it start with 0', () => {
4040
const value = '005A00ABC';
41-
const result1 = checkmarkFormatter(0, 0, value, {} as Column, {});
41+
const result1 = checkmarkFormatter(0, 0, value, {} as Column, {}, {});
4242
expect(result1).toBe('<i class="fa fa-check checkmark-icon" aria-hidden="true"></i>');
4343
});
4444

4545
it('should return an empty string when the string "0" is provided', () => {
4646
const value = '0';
47-
const result = checkmarkFormatter(0, 0, value, {} as Column, {});
47+
const result = checkmarkFormatter(0, 0, value, {} as Column, {}, {});
4848
expect(result).toBe('');
4949
});
5050

5151
it('should return the Font Awesome Checkmark icon when input is a number greater than 0', () => {
5252
const value = 0.000001;
53-
const result1 = checkmarkFormatter(0, 0, value, {} as Column, {});
53+
const result1 = checkmarkFormatter(0, 0, value, {} as Column, {}, {});
5454
expect(result1).toBe('<i class="fa fa-check checkmark-icon" aria-hidden="true"></i>');
5555
});
5656

5757
it('should return the Font Awesome Checkmark icon when input is a number as a text greater than 0', () => {
5858
const value = '0.000001';
59-
const result1 = checkmarkFormatter(0, 0, value, {} as Column, {});
59+
const result1 = checkmarkFormatter(0, 0, value, {} as Column, {}, {});
6060
expect(result1).toBe('<i class="fa fa-check checkmark-icon" aria-hidden="true"></i>');
6161
});
6262

6363
it('should return an empty string when input is a number lower or equal to 0', () => {
6464
const value1 = 0;
6565
const value2 = -0.5;
66-
const result1 = checkmarkFormatter(0, 0, value1, {} as Column, {});
67-
const result2 = checkmarkFormatter(0, 0, value2, {} as Column, {});
66+
const result1 = checkmarkFormatter(0, 0, value1, {} as Column, {}, {});
67+
const result2 = checkmarkFormatter(0, 0, value2, {} as Column, {}, {});
6868
expect(result1).toBe('');
6969
expect(result2).toBe('');
7070
});
7171

7272
it('should return an empty string when input is a number as a text and lower or equal to 0', () => {
7373
const value1 = '0';
7474
const value2 = '-0.5';
75-
const result1 = checkmarkFormatter(0, 0, value1, {} as Column, {});
76-
const result2 = checkmarkFormatter(0, 0, value2, {} as Column, {});
75+
const result1 = checkmarkFormatter(0, 0, value1, {} as Column, {}, {});
76+
const result2 = checkmarkFormatter(0, 0, value2, {} as Column, {}, {});
7777
expect(result1).toBe('');
7878
expect(result2).toBe('');
7979
});
8080

8181
it('should return an empty string when input is type null or undefined', () => {
8282
const value1 = null;
8383
const value2 = undefined;
84-
const result1 = checkmarkFormatter(0, 0, value1, {} as Column, {});
85-
const result2 = checkmarkFormatter(0, 0, value2, {} as Column, {});
84+
const result1 = checkmarkFormatter(0, 0, value1, {} as Column, {}, {});
85+
const result2 = checkmarkFormatter(0, 0, value2, {} as Column, {}, {});
8686
expect(result1).toBe('');
8787
expect(result2).toBe('');
8888
});
8989

9090
it('should return the Font Awesome Checkmark icon when input is the "null" or "undefined"', () => {
9191
const value1 = 'null';
9292
const value2 = 'undefined';
93-
const result1 = checkmarkFormatter(0, 0, value1, {} as Column, {});
94-
const result2 = checkmarkFormatter(0, 0, value2, {} as Column, {});
93+
const result1 = checkmarkFormatter(0, 0, value1, {} as Column, {}, {});
94+
const result2 = checkmarkFormatter(0, 0, value2, {} as Column, {}, {});
9595
expect(result1).toBe('<i class="fa fa-check checkmark-icon" aria-hidden="true"></i>');
9696
expect(result2).toBe('<i class="fa fa-check checkmark-icon" aria-hidden="true"></i>');
9797
});

0 commit comments

Comments
 (0)