Pretty printed code

This commit is contained in:
litetex
2020-04-09 19:38:39 +02:00
parent 3894eede2d
commit 7b228edf43
2 changed files with 107 additions and 91 deletions

View File

@ -16,60 +16,59 @@ import * as installer from '../src/installer';
const IS_WINDOWS = process.platform === 'win32';
describe('version tests', () => {
each([
'3.1.999',
'3.1.101-preview'
]).test("Exact version '%s' should be the same", vers => {
let versInfo = new installer.DotNetVersionInfo(vers);
each(['3.1.999', '3.1.101-preview']).test(
"Exact version '%s' should be the same",
vers => {
let versInfo = new installer.DotNetVersionInfo(vers);
expect(versInfo.isExactVersion()).toBe(true);
expect(versInfo.version()).toBe(vers);
})
expect(versInfo.isExactVersion()).toBe(true);
expect(versInfo.version()).toBe(vers);
}
);
each([['3.1.x', '3.1'], ['1.1.*', '1.1'], ['2.0', '2.0']]).test(
"Generic version '%s' should be '%s'",
(vers, resVers) => {
let versInfo = new installer.DotNetVersionInfo(vers);
expect(versInfo.isExactVersion()).toBe(false);
expect(versInfo.version()).toBe(resVers);
}
);
each([
['3.1.x', '3.1'],
['1.1.*', '1.1'],
['2.0', '2.0']
]).test("Generic version '%s' should be '%s'", (vers, resVers) => {
let versInfo = new installer.DotNetVersionInfo(vers);
expect(versInfo.isExactVersion()).toBe(false);
expect(versInfo.version()).toBe(resVers);
})
each([
"",
".",
"..",
" . ",
". ",
" .",
" . . ",
" .. ",
" . ",
"-1.-1",
"-1",
"-1.-1.-1",
"..3",
"1..3",
"1..",
".2.3",
".2.x",
"1",
"2.x",
"*.*.1",
"*.1",
"*.",
"1.2.",
"1.2.-abc",
"a.b",
"a.b.c",
"a.b.c-preview",
" 0 . 1 . 2 ",
'',
'.',
'..',
' . ',
'. ',
' .',
' . . ',
' .. ',
' . ',
'-1.-1',
'-1',
'-1.-1.-1',
'..3',
'1..3',
'1..',
'.2.3',
'.2.x',
'1',
'2.x',
'*.*.1',
'*.1',
'*.',
'1.2.',
'1.2.-abc',
'a.b',
'a.b.c',
'a.b.c-preview',
' 0 . 1 . 2 '
]).test("Malformed version '%s' should throw", vers => {
expect(() => new installer.DotNetVersionInfo(vers)).toThrow();
})
})
});
});
describe('installer tests', () => {
beforeAll(async () => {
@ -86,26 +85,35 @@ describe('installer tests', () => {
}
}, 100000);
it('Resolving a normal generic version works', async() => {
it('Resolving a normal generic version works', async () => {
const dotnetInstaller = new installer.DotnetCoreInstaller('3.1.x');
let versInfo = await dotnetInstaller.resolveInfos(["win-x64"],new installer.DotNetVersionInfo('3.1.x'));
let versInfo = await dotnetInstaller.resolveInfos(
['win-x64'],
new installer.DotNetVersionInfo('3.1.x')
);
expect(versInfo.resolvedVersion.startsWith('3.1.'));
}, 100000);
it('Resolving a nonexistent generic version fails', async() => {
it('Resolving a nonexistent generic version fails', async () => {
const dotnetInstaller = new installer.DotnetCoreInstaller('999.1.x');
try{
await dotnetInstaller.resolveInfos(["win-x64"],new installer.DotNetVersionInfo('999.1.x'));
try {
await dotnetInstaller.resolveInfos(
['win-x64'],
new installer.DotNetVersionInfo('999.1.x')
);
fail();
} catch {
expect(true);
}
}, 100000);
it('Resolving a exact version works', async() => {
it('Resolving a exact version works', async () => {
const dotnetInstaller = new installer.DotnetCoreInstaller('3.1.201');
let versInfo = await dotnetInstaller.resolveInfos(["win-x64"],new installer.DotNetVersionInfo('3.1.201'));
let versInfo = await dotnetInstaller.resolveInfos(
['win-x64'],
new installer.DotNetVersionInfo('3.1.201')
);
expect(versInfo.resolvedVersion).toBe('3.1.201');
}, 100000);