Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganitzsh committed Nov 10, 2023
1 parent 239815b commit abb4884
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
39 changes: 29 additions & 10 deletions src/release.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { jest } from '@jest/globals';
import { $ } from 'execa';

import { gitCommits, gitPush, gitRepo } from './utilities/git.js';

Expand Down Expand Up @@ -33,7 +34,9 @@ const optionsOverride = {
verifyRelease: (jest.fn() as JestSpyBooleanPromise).mockResolvedValue(true),
};

beforeEach((): void => {
beforeEach(async (): Promise<void> => {
await $`git config --global init.defaultBranch master`;

execSpy.mockImplementation(async (): Promise<number> => 0);
getInputSpy.mockImplementation((name: string): string => {
if (name === InputParameters.CommitAssets) {
Expand Down Expand Up @@ -73,7 +76,7 @@ beforeEach((): void => {

describe('release', (): void => {
it('"feat" makes a minor release using the default release rules', async (): Promise<void> => {
expect.assertions(2);
expect.assertions(3);

// Generate git
const { cwd } = await gitRepo();
Expand All @@ -87,14 +90,16 @@ describe('release', (): void => {
const { release } = await import('./release.js');
const result = await release(optionsOverride, configurationOverride);

expect(result).not.toBe(false);

if (result !== false) {
expect(result.nextRelease.type).toBe('minor');
expect(result.nextRelease.version).toBe('1.1.0');
}
});

it('"feat" with a BREAKING CHANGE makes a major release using the default release rules', async (): Promise<void> => {
expect.assertions(2);
expect.assertions(3);

// Generate git
const { cwd } = await gitRepo();
Expand All @@ -118,7 +123,7 @@ describe('release', (): void => {
});

it('"fix" makes a patch release using the default release rules', async (): Promise<void> => {
expect.assertions(2);
expect.assertions(3);

// Generate git
const { cwd } = await gitRepo();
Expand All @@ -132,14 +137,16 @@ describe('release', (): void => {
const { release } = await import('./release.js');
const result = await release(optionsOverride, configurationOverride);

expect(result).not.toBe(false);

if (result !== false) {
expect(result.nextRelease.type).toBe('patch');
expect(result.nextRelease.version).toBe('1.0.1');
}
});

it('"perf" makes a patch release using the default release rules', async (): Promise<void> => {
expect.assertions(2);
expect.assertions(3);

// Generate git
const { cwd } = await gitRepo();
Expand All @@ -153,14 +160,16 @@ describe('release', (): void => {
const { release } = await import('./release.js');
const result = await release(optionsOverride, configurationOverride);

expect(result).not.toBe(false);

if (result !== false) {
expect(result.nextRelease.type).toBe('patch');
expect(result.nextRelease.version).toBe('1.0.1');
}
});

it('"build" makes a patch release using the default release rules', async (): Promise<void> => {
expect.assertions(2);
expect.assertions(3);

// Generate git
const { cwd } = await gitRepo();
Expand All @@ -174,14 +183,16 @@ describe('release', (): void => {
const { release } = await import('./release.js');
const result = await release(optionsOverride, configurationOverride);

expect(result).not.toBe(false);

if (result !== false) {
expect(result.nextRelease.type).toBe('patch');
expect(result.nextRelease.version).toBe('1.0.1');
}
});

it('"ci" makes a patch release using the default release rules', async (): Promise<void> => {
expect.assertions(2);
expect.assertions(3);

// Generate git
const { cwd } = await gitRepo();
Expand All @@ -195,14 +206,16 @@ describe('release', (): void => {
const { release } = await import('./release.js');
const result = await release(optionsOverride, configurationOverride);

expect(result).not.toBe(false);

if (result !== false) {
expect(result.nextRelease.type).toBe('patch');
expect(result.nextRelease.version).toBe('1.0.1');
}
});

it('"docs" makes a patch release using the default release rules', async (): Promise<void> => {
expect.assertions(2);
expect.assertions(3);

// Generate git
const { cwd } = await gitRepo();
Expand All @@ -216,14 +229,16 @@ describe('release', (): void => {
const { release } = await import('./release.js');
const result = await release(optionsOverride, configurationOverride);

expect(result).not.toBe(false);

if (result !== false) {
expect(result.nextRelease.type).toBe('patch');
expect(result.nextRelease.version).toBe('1.0.1');
}
});

it('"improvement" makes a patch release using the default release rules', async (): Promise<void> => {
expect.assertions(2);
expect.assertions(3);

// Generate git
const { cwd } = await gitRepo();
Expand All @@ -237,14 +252,16 @@ describe('release', (): void => {
const { release } = await import('./release.js');
const result = await release(optionsOverride, configurationOverride);

expect(result).not.toBe(false);

if (result !== false) {
expect(result.nextRelease.type).toBe('patch');
expect(result.nextRelease.version).toBe('1.0.1');
}
});

it('"refactor" makes a patch release using the default release rules', async (): Promise<void> => {
expect.assertions(2);
expect.assertions(3);

// Generate git
const { cwd } = await gitRepo();
Expand All @@ -258,6 +275,8 @@ describe('release', (): void => {
const { release } = await import('./release.js');
const result = await release(optionsOverride, configurationOverride);

expect(result).not.toBe(false);

if (result !== false) {
expect(result.nextRelease.type).toBe('patch');
expect(result.nextRelease.version).toBe('1.0.1');
Expand Down
2 changes: 0 additions & 2 deletions src/utilities/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export const gitRepo = async (): Promise<{
cwd: string;
repositoryUrl: string;
}> => {
await $`git config --global init.defaultBranch master`;

const { remoteRepositoryUrl } = await initGitRemote();

const cloneWorkingDirectory = await gitShallowClone(remoteRepositoryUrl);
Expand Down

0 comments on commit abb4884

Please sign in to comment.