Skip to content

Commit

Permalink
Revert "Merge pull request #71 from wednesday-solutions/feat/notifica…
Browse files Browse the repository at this point in the history
…tion_service_test"

This reverts commit bc9071d, reversing
changes made to c62a339.
  • Loading branch information
himanshu-wedensday committed Apr 11, 2024
1 parent 10424e8 commit b9e8e92
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 107 deletions.
4 changes: 2 additions & 2 deletions app/navigators/AppNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createStackNavigator } from '@react-navigation/stack';
import SplashScreen from '@scenes/SplashScreen/';
import ExampleScreen from '@scenes/ExampleScreen';
import { NavigationContainer } from '@react-navigation/native';
import { setTopLevelNavigator } from '../services/NavigationService';
import NavigationService from '../services/NavigationService';
const Stack = createStackNavigator();
/**
* The root screen contains the application's navigation.
Expand All @@ -12,7 +12,7 @@ const Stack = createStackNavigator();
*/
export default function AppNavigator() {
return (
<NavigationContainer ref={setTopLevelNavigator}>
<NavigationContainer ref={NavigationService.setTopLevelNavigator}>
<Stack.Navigator headerMode="none" initialRouteName="SplashScreen">
<Stack.Screen name="SplashScreen" component={SplashScreen} />
<Stack.Screen name="MainScreen" component={ExampleScreen} />
Expand Down
3 changes: 2 additions & 1 deletion app/scenes/RootScreen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { connect } from 'react-redux';
import { PropTypes } from 'prop-types';
import AppNavigator from '@navigators/AppNavigator';
import Container from '@atoms/Container';

import { rootScreenActions } from './reducer';
import React, { useEffect } from 'react';
import { setRefForTopLevelNavigtor } from '@app/services/NavigationService';
import setRefForTopLevelNavigtor from '@app/services/NavigationService';

const RootScreen = props => {
useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions app/scenes/RootScreen/saga.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { takeLatest } from 'redux-saga/effects';
import { navigateAndReset } from '@app/services/NavigationService';
import NavigationService from '@app/services/NavigationService';
import { rootScreenTypes } from './reducer';

/**
* The startup saga is the place to define behavior to execute when the application starts.
*/
export function* startup() {
setTimeout(() => navigateAndReset('MainScreen'), 1000);
setTimeout(() => NavigationService.navigateAndReset('MainScreen'), 1000);
}

/**
Expand Down
22 changes: 8 additions & 14 deletions app/scenes/RootScreen/tests/saga.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
/* eslint-disable sonarjs/no-duplicate-string */
/**
* Test sagas
*/

/* eslint-disable redux-saga/yield-effects */

import { takeLatest } from 'redux-saga/effects';
// import NavigationService from 'app/services/NavigationService';
import { navigateAndReset } from '@app/services/NavigationService';
import NavigationService from 'app/services/NavigationService';
import { timeout } from 'app/utils/testUtils';
import rootScreenSaga, { startup } from '../saga';
import { rootScreenTypes } from '../reducer';
import set from 'lodash/set';

const NavigationService = '@app/services/NavigationService';
jest.mock('@app/services/NavigationService', () => ({
...jest.requireActual('@app/services/NavigationService'),
navigateAndReset: jest.fn()
}));
describe('Tests for RootScreen sagas', () => {
afterEach(() => {
jest.clearAllMocks();
});
const setupTests = () => ({
generator: rootScreenSaga(),
submitSpy: jest.fn()
Expand All @@ -36,10 +25,15 @@ describe('Tests for RootScreen sagas', () => {

it('should ensure that the navigation service is called after waiting for 1000ms', async () => {
const method = startup();
NavigationService.setTopLevelNavigator({ dispatch: () => {} });
const navigateAndResetSpy = jest.spyOn(
NavigationService,
'navigateAndReset'
);
method.next();
await timeout(1000);
expect(navigateAndReset).toHaveBeenCalled();
expect(navigateAndReset).toHaveBeenCalledWith('MainScreen');
expect(navigateAndResetSpy).toHaveBeenCalled();
expect(navigateAndResetSpy).toHaveBeenCalledWith('MainScreen');
});

it('should ensure that the navigation service is called after waiting for 1000ms', async () => {
Expand Down
6 changes: 5 additions & 1 deletion app/services/NavigationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ function navigateAndReset(routeName, params) {
);
}

export { navigate, navigateAndReset, setTopLevelNavigator };
export default {
navigate,
navigateAndReset,
setTopLevelNavigator
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MockAdapter from 'axios-mock-adapter';
import { getApiClient } from 'app/utils/apiUtils';
import { getUser } from '../UserService';
import { getUser } from './UserService';

describe('UserService tests', () => {
it('should make the api call to "/quotes?count=1"', async () => {
Expand Down
32 changes: 0 additions & 32 deletions app/services/tests/navigate.test.js

This file was deleted.

34 changes: 0 additions & 34 deletions app/services/tests/navigateAndReset.test.js

This file was deleted.

20 changes: 0 additions & 20 deletions app/services/tests/setTopLevelNavigation.test.js

This file was deleted.

0 comments on commit b9e8e92

Please sign in to comment.