'use strict';

var lab = exports.lab = require('lab').script();
var code = require('code');

var findRange = require('../');

lab.experiment('findRange', function(){

  lab.test('works with different versions', function(done){
    var range = findRange('1.0.0', ['^0.9.0', '^1.0.0', '^2.0.0']);
    code.expect(range).to.equal('^1.0.0');
    done();
  });

  lab.test('works with multiple matching versions', function(done){
    var range = findRange('1.2.0', ['^1.0.0', '^1.1.0', '^1.2.0']);
    code.expect(range).to.equal('^1.2.0');
    done();
  });

  lab.test('returns null with no matching versions', function(done){
    var range = findRange('1.2.0', ['~1.0.0', '~1.1.0']);
    code.expect(range).to.equal(null);
    done();
  });
});

@@ -193,23 +193,21 @@
 fferent 
-version
+range
 s', func
@@ -381,39 +381,37 @@
 ltiple matching 
-version
+range
 s', function(don
@@ -590,15 +590,602 @@
 ing 
-version
+ranges', function(done)%7B%0A    var range = findRange('1.2.0', %5B'~1.0.0', '~1.1.0'%5D);%0A    code.expect(range).to.equal(null);%0A    done();%0A  %7D);%0A%0A  lab.test('prerelease ranges', function(done)%7B%0A    var range = findRange('1.0.0-alpha.1', %5B'%5E1.0.0-alpha.1', '%5E1.0.0-beta.1'%5D);%0A    code.expect(range).to.equal('%5E1.0.0-alpha.1');%0A    done();%0A  %7D);%0A%0A  lab.test('prerelease ranges against release version', function(done)%7B%0A    var range = findRange('1.0.0', %5B'%5E1.0.0-alpha.1', '%5E1.0.0-beta.1'%5D);%0A    code.expect(range).to.equal('%5E1.0.0-beta.1');%0A    done();%0A  %7D);%0A%0A  lab.test('prerelease and release range
 s', 
@@ -1229,33 +1229,33 @@
 ange('1.2.0', %5B'
-~
+%5E
 1.0.0', '~1.1.0'
@@ -1239,38 +1239,63 @@
 0', %5B'%5E1.0.0', '
-~1.1.0
+%5E1.0.0-alpha.1', '%5E1.0.0-beta.1
 '%5D);%0A    code.ex
@@ -1307,36 +1307,288 @@
 range).to.equal(
-null
+'%5E1.0.0');%0A    done();%0A  %7D);%0A%0A  lab.test('prerelease and release ranges against prerelease version', function(done)%7B%0A    var range = findRange('1.0.0-beta.1', %5B'%5E1.0.0', '%5E1.0.0-alpha.1', '%5E1.0.0-alpha.2'%5D);%0A    code.expect(range).to.equal('%5E1.0.0-alpha.2'
 );%0A    done();%0A 

Improve test names & add prerelease tests