Skip to content

Commit

Permalink
fix hop command without parameters (#24)
Browse files Browse the repository at this point in the history
* fix hop command without parameters

* extra test case
  • Loading branch information
Opeyem1a authored Sep 26, 2024
1 parent bc3319e commit b5a0c6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 17 additions & 6 deletions src/commands/hop.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,23 @@ vi.mock('../services/git.js', () => {

describe('correctly renders hop UI', () => {
it('displays branch names in a list', async () => {
const actual = render(
const actual1 = render(
<Hop
cli={{
flags: {},
unnormalizedFlags: {},
}}
input={[]}
input={['hop']}
/>
);

const actual2 = render(
<Hop
cli={{
flags: {},
unnormalizedFlags: {},
}}
input={['h']}
/>
);

Expand All @@ -52,7 +62,8 @@ describe('correctly renders hop UI', () => {
);

await delay(100);
expect(actual.lastFrame()).to.equal(expected.lastFrame());
expect(actual1.lastFrame()).to.equal(expected.lastFrame());
expect(actual2.lastFrame()).to.equal(expected.lastFrame());
});

it('explains when no branches match the searched pattern', async () => {
Expand All @@ -62,7 +73,7 @@ describe('correctly renders hop UI', () => {
flags: {},
unnormalizedFlags: {},
}}
input={['nonexistent-branch-name']}
input={['hop', 'nonexistent-branch-name']}
/>
);
await delay(100);
Expand All @@ -87,7 +98,7 @@ describe('correctly renders hop UI', () => {
flags: {},
unnormalizedFlags: {},
}}
input={[]}
input={['hop']}
/>
);

Expand All @@ -104,7 +115,7 @@ describe('correctly renders hop UI', () => {
flags: {},
unnormalizedFlags: {},
}}
input={[]}
input={['hop']}
/>
);
await delay(100);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/hop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function Hop({ input }: CommandProps) {
const [newBranch, setNewBranch] = useState<string | undefined>(undefined);
const [error, setError] = useState<Error | undefined>(undefined);

const [searchTerm]: Array<string | undefined> = input;
const [, searchTerm]: Array<string | undefined> = input;

useEffect(() => {
if (currentBranch) return;
Expand Down

0 comments on commit b5a0c6a

Please sign in to comment.