Skip to content

Commit

Permalink
refactor: test updates for Lifecycle change
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jun 27, 2023
1 parent 789dcc4 commit e0d3124
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/org/scratchOrgLifecycleEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { Lifecycle } from '../lifecycleEvents';
import { AuthFields } from './authInfo';
import { ScratchOrgInfo } from './scratchOrgTypes';

const emitter = Lifecycle.getInstance();

export const scratchOrgLifecycleEventName = 'scratchOrgLifecycleEvent';
export const scratchOrgLifecycleStages = [
'prepare request',
Expand All @@ -26,7 +24,7 @@ export interface ScratchOrgLifecycleEvent {
}

export const emit = async (event: ScratchOrgLifecycleEvent): Promise<void> =>
emitter.emit(scratchOrgLifecycleEventName, event);
Lifecycle.getInstance().emit(scratchOrgLifecycleEventName, event);

const postOrgCreateHookFields = [
'accessToken',
Expand All @@ -47,7 +45,7 @@ const isHookField = (key: string): key is (typeof postOrgCreateHookFields)[numbe
postOrgCreateHookFields.includes(key as (typeof postOrgCreateHookFields)[number]);

export const emitPostOrgCreate = async (authFields: AuthFields): Promise<void> => {
await emitter.emit(
await Lifecycle.getInstance().emit(
'postorgcreate',
Object.fromEntries(Object.entries(authFields).filter(([key]) => isHookField(key))) as PostOrgCreateHook
);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lifecycleEventsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('lifecycleEvents', () => {
const fake = new Foo();

beforeEach(() => {
loggerSpy = spyMethod($$.SANDBOX, Lifecycle.getInstance(), 'debug');
loggerSpy = spyMethod($$.SANDBOX, $$.TEST_LOGGER, 'debug');
fakeSpy = spyMethod($$.SANDBOX, fake, 'bar');
});

Expand Down

0 comments on commit e0d3124

Please sign in to comment.