From e099c5b5721afcae40d1ad3cc2c8b4e5bde00731 Mon Sep 17 00:00:00 2001 From: Brian Hann Date: Mon, 16 Feb 2015 09:58:36 -0600 Subject: [PATCH] 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. --- DEVELOPER.md | 4 ++++ test/unit/core/services/rowSearcher.spec.js | 18 +++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/DEVELOPER.md b/DEVELOPER.md index 1816d2b4d3..fad118f3fd 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -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. diff --git a/test/unit/core/services/rowSearcher.spec.js b/test/unit/core/services/rowSearcher.spec.js index a31f33bc16..06f03268c1 100644 --- a/test/unit/core/services/rowSearcher.spec.js +++ b/test/unit/core/services/rowSearcher.spec.js @@ -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'); }); }); }); \ No newline at end of file