Skip to content

Commit

Permalink
chore(Tests): Fixed new Date() calls for Safari
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
c0bra committed Feb 16, 2015
1 parent 382f0ae commit e099c5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions DEVELOPER.md
Expand Up @@ -397,6 +397,10 @@ Deployment to http://ui-grid.info/ is done automatically when pushed to ui-grid
1. Use snake-case for class names, not camelCase.
# Tests
* **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')`.
# Performing a release
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.
Expand Down
18 changes: 9 additions & 9 deletions test/unit/core/services/rowSearcher.spec.js
Expand Up @@ -13,28 +13,28 @@ describe('rowSearcher', function() {
it('should be able to compare dates', function() {
var grid = {
getCellValue: function() {
return '2015-05-23';
return '2015/05/23';
}
};

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

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

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

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

0 comments on commit e099c5b

Please sign in to comment.