Skip to content

Commit

Permalink
Add test for changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Jul 19, 2024
1 parent 5758a00 commit 1719c78
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions node-src/git/findAncestorBuildWithCommit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const makeBuild = (build: Partial<Build> = {}): Build => ({
number: 1,
commit: 'missing',
uncommittedHash: '',
isLocalBuild: false,
...build,
});
const makeResult = (ancestorBuilds: Build[]): AncestorBuildsQueryResult => ({
Expand All @@ -36,14 +37,24 @@ describe('findAncestorBuildWithCommit', () => {
expect(client.runQuery.mock.calls[0][1]).toMatchObject({ buildNumber: 1 });
});

it('does not return build with uncommitted changes', async () => {
it('does not return a local build with uncommitted changes', async () => {
client.runQuery.mockReturnValue(
makeResult([makeBuild({ commit: 'exists', uncommittedHash: 'abc123' })])
makeResult([makeBuild({ commit: 'exists', uncommittedHash: 'abc123', isLocalBuild: true })])
);

expect(await findAncestorBuildWithCommit({ client }, 1, { page: 1, limit: 1 })).toBeNull();
});

it('DOES return a CI build with uncommitted changes', async () => {
client.runQuery.mockReturnValue(
makeResult([makeBuild({ commit: 'exists', uncommittedHash: 'abc123' })])
);

expect(await findAncestorBuildWithCommit({ client }, 1, { page: 1, limit: 1 })).toMatchObject({
commit: 'exists',
});
});

it('passes skip and limit and recurse', async () => {
const toFind = makeBuild({ number: 3, commit: 'exists' });
client.runQuery
Expand Down

0 comments on commit 1719c78

Please sign in to comment.