mocked helper in github repo create tests

Signed-off-by: Phred <fearphage@gmail.com>
This commit is contained in:
Phred
2023-03-28 08:07:50 -05:00
parent ec460fdbfc
commit 88627d957e
2 changed files with 6 additions and 2 deletions
@@ -28,6 +28,7 @@ import {
import { when } from 'jest-when';
import { PassThrough } from 'stream';
import { createGithubRepoCreateAction } from './githubRepoCreate';
import { familiarizeEntityName } from '../helpers';
const mockOctokit = {
rest: {
@@ -83,15 +84,17 @@ describe('github:repo:create', () => {
};
beforeEach(() => {
jest.resetAllMocks();
githubCredentialsProvider =
DefaultGithubCredentialsProvider.fromIntegrations(integrations);
action = createGithubRepoCreateAction({
integrations,
githubCredentialsProvider,
});
(familiarizeEntityName as jest.Mock).mockImplementation((s: string) => s);
});
afterEach(jest.resetAllMocks);
it('should call the githubApis with the correct values for createInOrg', async () => {
mockOctokit.rest.users.getByUsername.mockResolvedValue({
data: { type: 'Organization' },
@@ -90,7 +90,6 @@ describe('publish:github', () => {
};
beforeEach(() => {
jest.resetAllMocks();
githubCredentialsProvider =
DefaultGithubCredentialsProvider.fromIntegrations(integrations);
action = createPublishGithubAction({
@@ -105,6 +104,8 @@ describe('publish:github', () => {
);
});
afterEach(jest.resetAllMocks);
it('should fail to create if the team is not found in the org', async () => {
mockOctokit.rest.users.getByUsername.mockResolvedValue({
data: { type: 'Organization' },