Skip to content

Commit

Permalink
fix: Add support for node@17 in unit tests
Browse files Browse the repository at this point in the history
fix: Add support for node@17 in unit tests
  • Loading branch information
steveukx authored Nov 29, 2021
1 parent 27eebb1 commit 0d3bf47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [12.x, 14.x, 16.x, 17.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Node Version
run: node --version
- name: Git Version
run: git --version
- name: Cache node_modules
id: cache-modules
uses: actions/cache@v1
Expand Down
11 changes: 9 additions & 2 deletions test/integration/merge-integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ describe('merge', () => {
// merging second will fail on `aaa.txt` and `ccc.txt` due to the same line changing
// but `bbb.txt` will merge fine because they changed at opposing ends of the file
const mergeError = await promiseError<GitResponseError<MergeResult>>(git.merge([SECOND_BRANCH]));

expect(mergeError?.git).toHaveProperty('failed', true);
expect(mergeError?.git).toHaveProperty('conflicts', [
expect(theConflicts(mergeError)).toEqual([
{'reason': 'add/add', 'file': 'ccc.txt'},
{
'reason': 'content',
'file': 'aaa.txt'
}]);
assertGitError(mergeError, 'CONFLICTS: ccc.txt:add/add, aaa.txt:content');
});

it('multiple files updated and merged', async () => {
Expand All @@ -77,4 +77,11 @@ describe('merge', () => {
expect(await git.merge([SECOND_BRANCH])).toEqual(like({failed: false}));
});

function theConflicts(mergeError?: GitResponseError<MergeResult>) {
if (!mergeError?.git.conflicts) {
throw new Error(`expectTheConflicts called on non-error response`);
}

return [ ...mergeError.git.conflicts ].sort((a, b) => a.reason > b.reason ? 1 : -1);
}
});
4 changes: 3 additions & 1 deletion test/unit/merge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ CONFLICT (content): Merge conflict in readme.md
Automatic merge failed; fix conflicts and then commit the result.
`);
const error = await promiseError(queue);
assertGitResponseError(error, MergeSummaryDetail, like({failed: true}))
assertGitResponseError(error, MergeSummaryDetail, like({failed: true}));
assertGitError(error, 'CONFLICTS: readme.md:content');
});

it('responds with a MergeResult', async () => {
Expand Down Expand Up @@ -140,6 +141,7 @@ Automatic merge failed; fix conflicts and then commit the result.
],
})
);
expect(String(mergeSummary)).toEqual('CONFLICTS: ccc.ccc:add/add, aaa.aaa:content');
});

it('names conflicts when they exist', () => {
Expand Down

0 comments on commit 0d3bf47

Please sign in to comment.