diff --git a/packages/backend/src/index.test.ts b/packages/backend/src/index.test.ts index b1c4c35..b7e0b8e 100644 --- a/packages/backend/src/index.test.ts +++ b/packages/backend/src/index.test.ts @@ -1,13 +1,11 @@ import { PluginEnvironment } from './types'; import { resolverResult } from './plugins/plugins_helper/googleAuthResolver'; -import { - AuthResolverCatalogUserQuery, - AuthResolverContext, - ProfileInfo, - SignInInfo, -} from '@backstage/plugin-auth-node'; import { TokenParams } from '@backstage/plugin-auth-backend'; +let mockProfile: any; +let mockSignInInfo: any; +let mockContext: any; + describe('test', () => { it('unbreaks the test runner', () => { const unbreaker = {} as PluginEnvironment; @@ -16,31 +14,21 @@ describe('test', () => { }); describe('providers.google.create.signIn.resolver logic', () => { - const mockProfile: ProfileInfo = { - email: 'test.example.com', - displayName: 'John Doe', - picture: 'https://example.com/avatar.jpg', - }; - - const mockSignInInfo: SignInInfo = { - profile: mockProfile, - result: {}, // Placeholder for the authentication result - }; - - const mockContext: AuthResolverContext = { - issueToken: (params: TokenParams) => { - // Mock implementation for issueToken method - return { token: params.claims.sub + params.claims.ent }; - }, - findCatalogUser: (query: AuthResolverCatalogUserQuery) => { - // Mock implementation for findCatalogUser method - return ''; - }, - signInWithCatalogUser: (query: AuthResolverCatalogUserQuery) => { - // Mock implementation for signInWithCatalogUser method - return ''; - }, - }; + beforeEach(() => { + mockProfile = { + displayName: 'John Doe', + picture: 'https://example.com/avatar.jpg', + }; + mockSignInInfo = { profile: mockProfile, result: {} }; + mockContext = { + issueToken: (params: TokenParams) => { + // Mock implementation for issueToken method + return { token: params.claims.sub + params.claims.ent }; + }, + findCatalogUser: jest.fn(), + signInWithCatalogUser: jest.fn(), + }; + }); it('should throw an exception for empty email address', async () => { mockProfile.email = '';