Skip to content

Commit

Permalink
chore: move util function to shared file
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Nov 14, 2024
1 parent 818f795 commit 6213a38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 1 addition & 11 deletions packages/app/__tests__/app.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it, jest } from '@jest/globals';

import { checkV9Deprecation } from '../lib/common/unitTestUtils';
import firebase, {
deleteApp,
registerVersion,
Expand All @@ -10,16 +10,6 @@ import firebase, {
setLogLevel,
} from '../lib';

// this could be extracted to some test utils location
const checkV9Deprecation = (modularFunction: () => void, nonModularFunction: () => void) => {
const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
modularFunction();
expect(consoleWarnSpy).not.toHaveBeenCalled();
nonModularFunction();
expect(consoleWarnSpy).toHaveBeenCalledTimes(1);
consoleWarnSpy.mockRestore();
};

describe('App', function () {
describe('modular', function () {
it('`deleteApp` function is properly exposed to end user', function () {
Expand Down
10 changes: 10 additions & 0 deletions packages/app/lib/common/unitTestUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect, jest } from '@jest/globals';

export const checkV9Deprecation = (modularFunction: () => void, nonModularFunction: () => void) => {
const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
modularFunction();
expect(consoleWarnSpy).not.toHaveBeenCalled();
nonModularFunction();
expect(consoleWarnSpy).toHaveBeenCalledTimes(1);
consoleWarnSpy.mockRestore();
};

0 comments on commit 6213a38

Please sign in to comment.