Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unit tests to app/utils/notification #8140

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix tests
  • Loading branch information
enahum committed Aug 12, 2024
commit 974f79737c150f04404746a1588b403af1575cb3
3 changes: 2 additions & 1 deletion app/utils/notification/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ describe('Notification Utils', () => {

describe('emitNotificationError', () => {
it('should emit notification error after 500ms', (done) => {
const spyEmit = jest.spyOn(DeviceEventEmitter, 'emit');
emitNotificationError('Channel');
setTimeout(() => {
expect(DeviceEventEmitter.emit).toHaveBeenCalledWith(Events.NOTIFICATION_ERROR, 'Channel');
expect(spyEmit).toHaveBeenCalledWith(Events.NOTIFICATION_ERROR, 'Channel');
done();
}, 600); // wait a little longer than 500ms to ensure the timeout has executed
});
Expand Down
7 changes: 0 additions & 7 deletions test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ jest.doMock('react-native', () => {
InteractionManager: RNInteractionManager,
NativeModules: RNNativeModules,
Linking: RNLinking,
DeviceEventEmitter: RNDeviceEventEmitter,
} = ReactNative;

const Alert = {
Expand All @@ -89,11 +88,6 @@ jest.doMock('react-native', () => {
runAfterInteractions: jest.fn((cb) => cb()),
};

const DeviceEventEmitter = {
...RNDeviceEventEmitter,
emit: jest.fn(),
};

const NativeModules = {
...RNNativeModules,
UIManager: {
Expand Down Expand Up @@ -221,7 +215,6 @@ jest.doMock('react-native', () => {
InteractionManager,
NativeModules,
Linking,
DeviceEventEmitter,
}, ReactNative);
});

Expand Down