From 29cdcebc0798dd72f4cd43eb0c49a35642b5cc20 Mon Sep 17 00:00:00 2001 From: Sascha Mann Date: Mon, 11 Nov 2019 18:40:43 +0100 Subject: [PATCH] Add tests for range input --- __tests__/main.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 93aa1a7..fad41f0 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -1,5 +1,7 @@ import * as installer from '../src/installer' +const testVersions = ['v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0'] + describe('installer tests', () => { describe('version matching', () => { describe('specific versions', () => { @@ -13,5 +15,13 @@ describe('installer tests', () => { expect(await installer.getJuliaVersion([], '1.3.0-rc2')).toEqual('1.3.0-rc2') }) }) + describe('version ranges', () => { + it('Chooses the highest available version that matches the input', async () => { + expect(await installer.getJuliaVersion(testVersions, '1')).toEqual('1.2.0') + expect(await installer.getJuliaVersion(testVersions, '1.0')).toEqual('1.0.5') + expect(await installer.getJuliaVersion(testVersions, '^1.3.0-rc1')).toEqual('1.3.0-rc4') + expect(await installer.getJuliaVersion(testVersions, '^1.2.0-rc1')).toEqual('1.2.0') + }) + }) }) })