Skip to content

Commit

Permalink
UPD: Refactored the tests and moved domain to .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
MennaTullahTaha committed May 14, 2024
1 parent afa00c5 commit 1805e30
Showing 1 changed file with 19 additions and 31 deletions.
50 changes: 19 additions & 31 deletions packages/backend/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<any> = {
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 = '';
Expand Down

0 comments on commit 1805e30

Please sign in to comment.