Skip to content

Commit e099c5b

Browse files
committed
chore(Tests): Fixed new Date() calls for Safari
Commit 0259aab added tests for rowSearcher but they were failing on Safari 5 because it doesn't allow creating dates from strings where the delimiter is a dash. Changed to slashes. Also updated DEVELOPER.md to include this as a warning for test creation.
1 parent 382f0ae commit e099c5b

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

DEVELOPER.md

+4
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ Deployment to http://ui-grid.info/ is done automatically when pushed to ui-grid
397397
398398
1. Use snake-case for class names, not camelCase.
399399
400+
# Tests
401+
402+
* **Note:** Safari 5 does not allow creating dates from strings where the delimiter is a dash, i.e. `new Date('2015-5-23')` will fail. This will cause your tests to work on all browsers but bomb on Safari 5 and you will have a hard time discovering why. Instead, use slashes like so: `new Date('2015/5/23')`.
403+
400404
# Performing a release
401405
402406
Run these grunt tasks. Look at the grunt-bump module for how to specify a major/minor/patch/pre-release version. This series will bump the version in package.json, update the changelog for that version, then commit the changes and add a new git tag for the version.

test/unit/core/services/rowSearcher.spec.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@ describe('rowSearcher', function() {
1313
it('should be able to compare dates', function() {
1414
var grid = {
1515
getCellValue: function() {
16-
return '2015-05-23';
16+
return '2015/05/23';
1717
}
1818
};
1919

2020
var filter = {
21-
term: '2015-05-24',
21+
term: '2015/05/24',
2222
flags: { date: true },
2323
condition: uiGridConstants.filter.GREATER_THAN
2424
};
25-
expect(rowSearcher.runColumnFilter(grid, 1, 2, filter)).toBe(false);
25+
expect(rowSearcher.runColumnFilter(grid, 1, 2, filter)).toBe(false, 'date not greater than');
2626

27-
filter.term = '2015-05-22';
27+
filter.term = '2015/05/22';
2828
filter.condition = uiGridConstants.filter.GREATER_THAN;
29-
expect(rowSearcher.runColumnFilter(grid, 1, 2, filter)).toBe(true);
29+
expect(rowSearcher.runColumnFilter(grid, 1, 2, filter)).toBe(true, 'date is greater than');
3030

31-
filter.term = '2015-05-24';
31+
filter.term = '2015/05/24';
3232
filter.condition = uiGridConstants.filter.GREATER_THAN;
33-
expect(rowSearcher.runColumnFilter(grid, 1, 2, filter)).toBe(false);
33+
expect(rowSearcher.runColumnFilter(grid, 1, 2, filter)).toBe(false, 'date not greater than again');
3434

35-
filter.term = '2015-05-23';
35+
filter.term = '2015/05/23';
3636
filter.condition = uiGridConstants.filter.GREATER_THAN_OR_EQUAL_TO;
37-
expect(rowSearcher.runColumnFilter(grid, 1, 2, filter)).toBe(true);
37+
expect(rowSearcher.runColumnFilter(grid, 1, 2, filter)).toBe(true, 'date greater than or equal to');
3838
});
3939
});
4040
});

0 commit comments

Comments
 (0)