From 609f3d27bf3a5b0c0b0e1c1bdd34720e7e48174a Mon Sep 17 00:00:00 2001 From: kerbyfc Date: Thu, 16 Jun 2016 12:18:35 +0300 Subject: [PATCH] Add test for bowser.compareVersions --- test/test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/test.js b/test/test.js index c11e035..c78dcb2 100644 --- a/test/test.js +++ b/test/test.js @@ -73,3 +73,25 @@ for (g in allUserAgents) { (function(group, userAgents) { }) })(g, allUserAgents[g])} + +var comparisionsTasks = [ + ['9.0', '10', -1], + ['11', '10', 1], + ['1.10.2.1', '1.8.2.1.90', 1], + ['1.010.2.1', '1.08.2.1.90', 1], + ['1.10.2.1', '1.10.2.1', 0], + ['1.10.2.1', '1.0800.2', -1], +]; + +describe('Browser versions comparision', function() { + + for(g in comparisionsTasks) { + var task = comparisionsTasks[g], + version = task[0], + version2 = task[1], + matching = task[2] === 0 ? ' == ' : (task[2] > 0) ? ' > ' : ' < '; + it('version ' + version + ' should be' + matching + 'version ' + version2, function(){ + assert.equal(browser.compareVersions([version, version2]), task[2]); + }) + } +});