Skip to content

Commit

Permalink
Update tests according to new api
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolai-laevskii committed Sep 4, 2023
1 parent 67c4cb7 commit cd87e99
Showing 1 changed file with 48 additions and 9 deletions.
57 changes: 48 additions & 9 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ describe('installer tests', () => {
const inputQuality = '' as QualityOptions;
const errorMessage = 'fictitious error message!';

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: 1,
Expand All @@ -51,7 +55,7 @@ describe('installer tests', () => {
});

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);
await expect(dotnetInstaller.installDotnet()).rejects.toThrow(
Expand All @@ -63,6 +67,11 @@ describe('installer tests', () => {
const inputVersion = '3.1.100';
const inputQuality = '' as QualityOptions;
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: 0,
Expand All @@ -73,7 +82,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);
const installedVersion = await dotnetInstaller.installDotnet();
Expand All @@ -86,6 +95,10 @@ describe('installer tests', () => {
const inputQuality = '' as QualityOptions;
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: 0,
Expand All @@ -96,7 +109,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand All @@ -123,6 +136,11 @@ describe('installer tests', () => {
const inputVersion = '6.0.300';
const inputQuality = 'ga' as QualityOptions;
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: 0,
Expand All @@ -133,7 +151,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand All @@ -149,6 +167,10 @@ describe('installer tests', () => {
const inputQuality = 'ga' as QualityOptions;
const stdout = `Fictitious dotnet version 3.1.100 is installed`;

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: 0,
Expand All @@ -159,7 +181,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand All @@ -173,6 +195,10 @@ describe('installer tests', () => {
each(['6', '6.0', '6.0.x', '6.0.*', '6.0.X']).test(
`should supply 'quality' argument to the installation script if quality input is set and version (%s) is not in A.B.C syntax`,
async inputVersion => {
const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

const inputQuality = 'ga' as QualityOptions;
const exitCode = 0;
const stdout = `Fictitious dotnet version 6.0.0 is installed`;
Expand All @@ -186,7 +212,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand Down Expand Up @@ -216,6 +242,11 @@ describe('installer tests', () => {
const inputQuality = '' as QualityOptions;
const exitCode = 0;
const stdout = `Fictitious dotnet version 6.0.0 is installed`;

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: exitCode,
Expand All @@ -226,7 +257,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand Down Expand Up @@ -257,6 +288,10 @@ describe('installer tests', () => {
const inputQuality = '' as QualityOptions;
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: 0,
Expand All @@ -267,7 +302,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand Down Expand Up @@ -295,6 +330,10 @@ describe('installer tests', () => {
const inputQuality = '' as QualityOptions;
const stdout = `Fictitious dotnet version 6.0.0 is installed`;

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: 0,
Expand All @@ -305,7 +344,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand Down

0 comments on commit cd87e99

Please sign in to comment.