Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,25 @@
"lint:fix": "biome check . --write"
},
"devDependencies": {
"@biomejs/biome": "2.2.4",
"@commitlint/cli": "^20.0.0",
"@commitlint/config-conventional": "^20.0.0",
"@effect/vitest": "0.25.1",
"@tsconfig/node22": "^22.0.2",
"@types/node": "^24.5.2",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/ui": "^3.2.4",
"lefthook": "^1.13.4",
"rimraf": "^6.0.1",
"typescript": "^5.9.2",
"vitest": "^3.2.4"
"@biomejs/biome": "2.4.6",
"@commitlint/cli": "^20.4.3",
"@commitlint/config-conventional": "^20.4.3",
"@effect/vitest": "0.27.0",
"@tsconfig/node22": "^22.0.5",
"@types/node": "^25.4.0",
"@vitest/coverage-v8": "^4.0.18",
"@vitest/ui": "^4.0.18",
"lefthook": "^2.1.3",
"rimraf": "^6.1.3",
"typescript": "^5.9.3",
"vitest": "^4.0.18"
},
"dependencies": {
"@effect/cli": "0.71.0",
"@effect/platform": "0.92.0",
"@effect/platform-node": "0.98.0",
"@effect/printer": "0.46.0",
"@effect/printer-ansi": "0.46.0",
"effect": "3.18.0"
"@effect/cli": "0.73.2",
"@effect/platform": "0.94.5",
"@effect/platform-node": "0.104.1",
"@effect/printer": "0.47.0",
"@effect/printer-ansi": "0.47.0",
"effect": "3.19.19"
}
}
2,194 changes: 863 additions & 1,331 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/commands/create/create.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import {
mockAppConfigService,
mockGitClient,
mockJiraClient,
resetTestMocks,
testLayer,
} from '../../test/mock-implementations.js';
import {GitBranch} from '../../types.js';
import {gitCreateJiraBranch} from './create.handler.js';

describe('gitCreateJiraBranch', () => {
beforeEach(() => {
vi.restoreAllMocks();
resetTestMocks();
vi.clearAllMocks();
});

live('should create feature branch', () =>
Expand Down
4 changes: 3 additions & 1 deletion src/commands/delete/delete.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import {BranchNotMerged} from '../../schema/branch-not-merged.js';
import {
mockAppConfigService,
mockGitClient,
resetTestMocks,
testLayer,
} from '../../test/mock-implementations.js';
import {GitBranch} from '../../types.js';
import {deleteBranch} from './delete.handler.js';

describe('deleteBranch', () => {
beforeEach(() => {
vi.restoreAllMocks();
resetTestMocks();
vi.clearAllMocks();
});

live('should delete branch', () =>
Expand Down
7 changes: 5 additions & 2 deletions src/commands/info/info.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import {
mockAppConfigService,
mockGitClient,
mockJiraClient,
resetTestMocks,
testLayer,
} from '../../test/mock-implementations.js';
import {ticketInfo, ticketInfoForCurrentBranch} from './info.handler.js';

describe('ticketInfo', () => {
beforeEach(() => {
vi.restoreAllMocks();
resetTestMocks();
vi.clearAllMocks();
});

live('should return info for a given ticket', () =>
Expand All @@ -35,7 +37,8 @@ describe('ticketInfo', () => {

describe('ticketInfoForCurrentBranch', () => {
beforeEach(() => {
vi.restoreAllMocks();
resetTestMocks();
vi.clearAllMocks();
});
live('should extract ticket from branch and return issue info', () =>
Effect.gen(function* () {
Expand Down
7 changes: 5 additions & 2 deletions src/commands/open/open.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import {beforeEach, describe, expect, vi} from 'vitest';
import {
mockAppConfigService,
mockGitClient,
resetTestMocks,
testLayer,
} from '../../test/mock-implementations.js';
import {ticketUrl, ticketUrlForCurrentBranch} from './open.handler.js';

describe('ticketUrl', () => {
beforeEach(() => {
vi.restoreAllMocks();
resetTestMocks();
vi.clearAllMocks();
});
live('should return appropriate url for given ticket key', () =>
Effect.gen(function* () {
Expand All @@ -30,7 +32,8 @@ describe('ticketUrl', () => {

describe('ticketUrlForCurrentBranch', () => {
beforeEach(() => {
vi.restoreAllMocks();
resetTestMocks();
vi.clearAllMocks();
});
live('should extract ticket from branch an return appropriate url', () =>
Effect.gen(function* () {
Expand Down
4 changes: 3 additions & 1 deletion src/commands/switch/switch.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import {beforeEach, describe, expect, vi} from 'vitest';
import {
mockAppConfigService,
mockGitClient,
resetTestMocks,
testLayer,
} from '../../test/mock-implementations.js';
import {GitBranch} from '../../types.js';
import {switchBranch} from './switch.handler.js';

describe('switchBranch', () => {
beforeEach(() => {
vi.restoreAllMocks();
resetTestMocks();
vi.clearAllMocks();
});
live('should switch to existing branch', () =>
Effect.gen(function* () {
Expand Down
34 changes: 33 additions & 1 deletion src/test/mock-implementations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as CommandExecutor from '@effect/platform/CommandExecutor';
import * as NodeFileSystem from '@effect/platform-node/NodeFileSystem';
import * as NodePath from '@effect/platform-node/NodePath';
import * as NodeTerminal from '@effect/platform-node/NodeTerminal';
import {Chunk, Effect, Layer} from 'effect';
import {Chunk, Effect, Layer, Option} from 'effect';

import {AppConfigService} from '../services/app-config.js';
import {GitClient} from '../services/git-client.js';
Expand All @@ -22,6 +22,38 @@ export const mockGitClient = {
export const mockAppConfigService = {getAppConfig: effectMock()};
export const mockJiraClient = {getJiraIssue: effectMock()};

export const resetTestMocks = (): void => {
mockGitClient.listBranches
.mockReset()
.mockImplementation(() => Effect.succeed(Chunk.empty<GitBranch>()));
mockGitClient.getCurrentBranch
.mockReset()
.mockImplementation(() => Effect.succeed(undefined));
mockGitClient.createGitBranch
.mockReset()
.mockImplementation(() => Effect.succeed(undefined));
mockGitClient.deleteBranch
.mockReset()
.mockImplementation(() => Effect.succeed(undefined));
mockGitClient.createGitBranchFrom.innerMock
.mockReset()
.mockImplementation(() => Effect.succeed(undefined));
mockGitClient.createGitBranchFrom
.mockReset()
.mockImplementation(() => mockGitClient.createGitBranchFrom.innerMock);
mockGitClient.switchBranch
.mockReset()
.mockImplementation(() => Effect.succeed(undefined));
mockAppConfigService.getAppConfig
.mockReset()
.mockImplementation(() =>
Effect.succeed({defaultJiraKeyPrefix: Option.none()}),
);
mockJiraClient.getJiraIssue
.mockReset()
.mockImplementation(() => Effect.succeed(undefined));
};

const noopCommandExecutor = CommandExecutor.makeExecutor(() =>
Effect.dieMessage('CommandExecutor should not be used in tests'),
);
Expand Down
2 changes: 1 addition & 1 deletion src/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type ToEffectMock = {

export const toEffectMock: ToEffectMock = (
// biome-ignore lint/suspicious/noExplicitAny: any okay in tests
fn: Mock<(args: any) => Effect.Effect<any, any>>,
fn: Mock<any>,
// biome-ignore lint/suspicious/noExplicitAny: any okay in tests
): EffectMock<any, any, any> => {
const mock = Object.assign(fn, {
Expand Down
Loading