Skip to content

Commit

Permalink
fix(test): updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kavitha Kesavalu committed Nov 2, 2024
1 parent 58b1e64 commit 6b4a34f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
testEnvironment: 'node',
extensionsToTreatAsEsm: ['.ts', '.mts'],
coveragePathIgnorePatterns: ['\\.mock\\.ts$'],
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
moduleFileExtensions: ['ts', 'mts', 'tsx', 'js', 'mjs', 'jsx', 'json', 'node'],
testRegex: '(/(__tests__|e2e)/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?|mts)$',
transform: {
Expand Down
3 changes: 3 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
beforeEach(() => {
process.env.SHEPHERD_GITHUB_ENTERPRISE_URL = 'https://api.github.com';
});
8 changes: 8 additions & 0 deletions src/adapters/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ jest.mock('simple-git');
jest.mock('fs-extra');

class TestGitAdapter extends GitAdapter {
// @ts-ignore
createIssue(repo: IRepo): Promise<string> {
return Promise.resolve('');
}
// @ts-ignore
updateIssue(repo: IRepo, issueNumber: number): Promise<void> {
return Promise.resolve();
}
// @ts-ignore
getCandidateRepos(onRetry: RetryMethod): Promise<IRepo[]> {
return Promise.resolve([]);
Expand Down
8 changes: 5 additions & 3 deletions src/adapters/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,19 @@ describe('GithubAdapter', () => {

it('returns the SSH URL, when not given a protocol', () => {
delete process.env.SHEPHERD_GITHUB_PROTOCOL;
expect(adapter['getRepositoryUrl'](repo)).toBe('[email protected]:NerdWallet/shepherd.git');
expect(adapter['getRepositoryUrl'](repo)).toBe('git@api.github.com:NerdWallet/shepherd.git');
});

it('returns the SSH URL, when given protocol=ssh', () => {
process.env.SHEPHERD_GITHUB_PROTOCOL = 'ssh';
expect(adapter['getRepositoryUrl'](repo)).toBe('[email protected]:NerdWallet/shepherd.git');
expect(adapter['getRepositoryUrl'](repo)).toBe('git@api.github.com:NerdWallet/shepherd.git');
});

it('returns the HTTPS URL when given protocol=https', () => {
process.env.SHEPHERD_GITHUB_PROTOCOL = 'https';
expect(adapter['getRepositoryUrl'](repo)).toBe('https://github.com/NerdWallet/shepherd.git');
expect(adapter['getRepositoryUrl'](repo)).toBe(
'https://api.github.com/NerdWallet/shepherd.git'
);
});

it('throws on unexpected protocols', () => {
Expand Down

0 comments on commit 6b4a34f

Please sign in to comment.