Skip to content

Commit

Permalink
feat: conflict resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-wedensday committed Apr 12, 2024
2 parents e28acda + 9f18cdc commit 92e6ee8
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 85 deletions.
6 changes: 5 additions & 1 deletion app/components/atoms/LanguageProvider/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
*/

import { CHANGE_LOCALE } from './constants';

/**
* Changes the locale/language of the application.
* @param {string} languageLocale - The new locale/language to set.
* @returns {object} An action object with type 'CHANGE_LOCALE' and the new locale/language.
*/
export function changeLocale(languageLocale) {

Check warning on line 13 in app/components/atoms/LanguageProvider/actions.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹 Function is not covered

Warning! Not covered function
return {
type: CHANGE_LOCALE,
Expand Down
15 changes: 13 additions & 2 deletions app/components/atoms/LanguageProvider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ import { createSelector } from 'reselect';
import { IntlProvider } from 'react-intl';

import { makeSelectLocale } from './selectors';

/**
* Provides internationalization (i18n) support by wrapping components with an IntlProvider.
* @param {object} props - The props object containing component properties.
* @param {string} props.locale - The locale/language code for internationalization.
* @param {object} props.messages - An object containing locale-specific message translations.
* @param {React.ReactNode} props.children - The child elements/components to be wrapped and rendered.
* @returns {React.ReactNode} A JSX element wrapping the provided child components with IntlProvider.
*/
export function LanguageProvider(props) {
return (
<IntlProvider
Expand All @@ -35,7 +42,11 @@ LanguageProvider.propTypes = {
const mapStateToProps = createSelector(makeSelectLocale(), locale => ({
locale
}));

/**
* Generates and returns an object containing action dispatch functions.
* @param {function} dispatch - The Redux store's dispatch function.
* @returns {object} An object containing action dispatch functions wrapped for use in components.
*/
function mapDispatchToProps(dispatch) {
return {
dispatch
Expand Down
7 changes: 6 additions & 1 deletion app/components/molecules/LogoWithInstructions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ const Instructions = styled(T)`
margin-bottom: 5;
font-style: italic;
`;

/**
* A component that displays a logo along with instructions.
* @param {object} props - The props object containing component properties.
* @param {string} props.instructions - The instructions text to display.
* @returns {React.ReactNode} JSX elements displaying the logo and instructions.
*/
function LogoWithInstructions({ instructions }) {
return (
<View>
Expand Down
9 changes: 8 additions & 1 deletion app/components/organisms/SimpsonsLoveWednesday/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ const SeparatedView = styled.View`
margin: 10px;
}
`;

/**
* A component that displays Simpsons-themed content related to Wednesday, including instructions, character details, and error messages.
* @param {object} props - The props object containing component properties.
* @param {string} props.instructions - The instructions text to display.
* @param {object} props.user - The user object representing character details and quote.
* @param {string} props.userErrorMessage - The error message to display if user data retrieval fails.
* @returns {React.ReactNode} JSX elements displaying Simpsons-themed content based on provided props.
*/
function SimpsonsLoveWednesday({ instructions, user, userErrorMessage }) {
return (
<>
Expand Down
6 changes: 5 additions & 1 deletion app/rootSaga.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { fork } from 'redux-saga/effects';
import exampleSaga from '@scenes/ExampleScreen/saga';
import startupSaga from '@scenes/RootScreen/saga';

/**
* Root saga generator function that orchestrates other sagas.
* This function sets up and manages the execution of multiple sagas using fork effects.
* @returns {IterableIterator<any>} An iterator for managing the execution of sagas.
*/
export default function* root() {
yield fork(exampleSaga);
yield fork(startupSaga);
Expand Down
6 changes: 5 additions & 1 deletion app/scenes/ExampleScreen/saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export function* fetchUser() {
);
}
}

/**
* Saga responsible for managing user search requests and fetching user data.
* Watches for specific action types and triggers corresponding worker sagas.
* @returns {IterableIterator<any>} An iterator for handling user search and data fetching.
*/
export default function* searchListContainerSaga() {
yield takeLatest(exampleScreenTypes.REQUEST_FETCH_USER, fetchUser);
}
35 changes: 14 additions & 21 deletions app/scenes/RootScreen/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { PropTypes } from 'prop-types';
import { setTopLevelNavigator } from '@services/NavigationService';
import AppNavigator from '@navigators/AppNavigator';
import Container from '@atoms/Container';

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

export class RootScreen extends Component {
componentDidMount() {
// Run the startup saga when the application is starting
this.props.startup();
}

setRefForTopLevelNavigtor = navigatorRef => {
setTopLevelNavigator(navigatorRef);
};
const RootScreen = props => {
useEffect(() => {
// Run the startup function when the component mounts
props.startup();
}, []);

render() {
return (
<Container testID="root-screen">
<AppNavigator />
</Container>
);
}
}
return (
<Container testID="root-screen">
<AppNavigator ref={setRefForTopLevelNavigtor} />
</Container>
);
};

RootScreen.propTypes = {
startup: PropTypes.func
Expand All @@ -33,5 +26,5 @@ RootScreen.propTypes = {
const mapDispatchToProps = dispatch => ({

Check warning on line 26 in app/scenes/RootScreen/index.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹 Function is not covered

Warning! Not covered function
startup: () => dispatch(rootScreenActions.startup())

Check warning on line 27 in app/scenes/RootScreen/index.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 27 in app/scenes/RootScreen/index.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹 Function is not covered

Warning! Not covered function
});

Check warning on line 28 in app/scenes/RootScreen/index.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

export default connect(null, mapDispatchToProps)(RootScreen);
export { RootScreen as RootScreenTest };
13 changes: 5 additions & 8 deletions app/scenes/RootScreen/tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@

import React from 'react';
import { renderWithIntl } from 'app/utils/testUtils';
import { RootScreen as RootScreenTest } from '../index';

import { RootScreenTest } from '../index';
export const setupJest = () => ({ submitSpy: jest.fn() });
describe('<HomeScreen /> container', () => {
let submitSpy;

beforeAll(() => {
submitSpy = jest.fn();
});

it('should render and match the snapshot', () => {
const { submitSpy } = setupJest();
const baseElement = renderWithIntl(<RootScreenTest startup={submitSpy} />);
expect(baseElement).toMatchSnapshot();
});

it('should call the startup prop on mount', () => {
const { submitSpy } = setupJest();
renderWithIntl(<RootScreenTest startup={submitSpy} />);
expect(submitSpy).toHaveBeenCalled();
});

it('should not render rootSceen Container', () => {
const { submitSpy } = setupJest();
const { getByTestId } = renderWithIntl(
<RootScreenTest startup={submitSpy} />
);
Expand Down
17 changes: 13 additions & 4 deletions app/scenes/RootScreen/tests/reducer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,30 @@ import {

/* eslint-disable default-case, no-param-reassign */
describe('Tests for RootScreen reducers', () => {
let state;
beforeEach(() => {
state = initialState;
});
const setupTests = () => ({ state: initialState });

it('should return the initial state', () => {
const { state } = setupTests();
expect(rootContainerReducer(undefined, {})).toEqual(state);
});

it('should return the initial state when an action of type STARTUP is dispatched', () => {
const { state } = setupTests();
// since startup is called to initiate screen navigation the store should remain intact
expect(
rootContainerReducer(state, {
type: rootScreenTypes.STARTUP
})
).toEqual(state);
});

it('should return the initial state when an action of type NONEXIST is dispatched', () => {
const { state } = setupTests();
// since startup is called to initiate screen navigation the store should remain intact
expect(
rootContainerReducer(state, {
type: rootScreenTypes.NONEXIST
})
).toEqual(state);
});
});
100 changes: 55 additions & 45 deletions app/themes/fonts.test.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,69 @@
import fonts from './fonts';
const fontSizes = {
small: {
expectation: expect.arrayContaining([
expect.stringContaining('font-size: 14px;')
])
},
regular: {
expectation: expect.arrayContaining([
expect.stringContaining('font-size: 17px;')
])
},
big: {
expectation: expect.arrayContaining([
expect.stringContaining('font-size: 20px;')
])
},
large: {
expectation: expect.arrayContaining([
expect.stringContaining('font-size: 24px;')
])
}
};

const fontWeights = {
light: {
expectation: expect.arrayContaining([
expect.stringContaining('font-weight: light;')
])
},
bold: {
expectation: expect.arrayContaining([
expect.stringContaining('font-weight: bold;')
])
},
normal: {
expectation: expect.arrayContaining([
expect.stringContaining('font-weight: normal;')
])
}
};

describe('Tests for fonts', () => {
it('should have the correct font-size', () => {
expect(fonts.size.small()).toEqual(
expect.arrayContaining([expect.stringContaining('font-size: 14px;')])
);
expect(fonts.size.regular()).toEqual(
expect.arrayContaining([expect.stringContaining('font-size: 17px;')])
);
expect(fonts.size.big()).toEqual(
expect.arrayContaining([expect.stringContaining('font-size: 20px;')])
);
expect(fonts.size.large()).toEqual(
expect.arrayContaining([expect.stringContaining('font-size: 24px;')])
);
expect(fonts.size.small()).toEqual(fontSizes.small.expectation);
expect(fonts.size.regular()).toEqual(fontSizes.regular.expectation);
expect(fonts.size.big()).toEqual(fontSizes.big.expectation);
expect(fonts.size.large()).toEqual(fontSizes.large.expectation);
});
it('should have the correct font-weight', () => {
expect(fonts.weights.light()).toEqual(
expect.arrayContaining([expect.stringContaining('font-weight: light;')])
);
expect(fonts.weights.bold()).toEqual(
expect.arrayContaining([expect.stringContaining('font-weight: bold;')])
);
expect(fonts.weights.normal()).toEqual(
expect.arrayContaining([expect.stringContaining('font-weight: normal;')])
);
expect(fonts.weights.light()).toEqual(fontWeights.light.expectation);
expect(fonts.weights.bold()).toEqual(fontWeights.bold.expectation);
expect(fonts.weights.normal()).toEqual(fontWeights.normal.expectation);
});

it('should have the correct font-weight and font-size', () => {
expect(fonts.style.heading()).toEqual(
expect.arrayContaining([expect.stringContaining('font-weight: bold;')])
);
expect(fonts.style.heading()).toEqual(
expect.arrayContaining([expect.stringContaining('font-size: 24px;')])
);
expect(fonts.style.heading()).toEqual(fontWeights.bold.expectation);
expect(fonts.style.heading()).toEqual(fontSizes.large.expectation);

expect(fonts.style.subheading()).toEqual(
expect.arrayContaining([expect.stringContaining('font-weight: bold;')])
);
expect(fonts.style.subheading()).toEqual(
expect.arrayContaining([expect.stringContaining('font-size: 20px;')])
);
expect(fonts.style.subheading()).toEqual(fontWeights.bold.expectation);
expect(fonts.style.subheading()).toEqual(fontSizes.big.expectation);

expect(fonts.style.standard()).toEqual(
expect.arrayContaining([expect.stringContaining('font-size: 17px;')])
);
expect(fonts.style.standard()).toEqual(
expect.arrayContaining([expect.stringContaining('font-weight: normal;')])
);
expect(fonts.style.standard()).toEqual(fontSizes.regular.expectation);
expect(fonts.style.standard()).toEqual(fontWeights.normal.expectation);

expect(fonts.style.subText()).toEqual(
expect.arrayContaining([expect.stringContaining('font-size: 14px;')])
);
expect(fonts.style.subText()).toEqual(
expect.arrayContaining([expect.stringContaining('font-weight: normal;')])
);
expect(fonts.style.subText()).toEqual(fontSizes.small.expectation);
expect(fonts.style.subText()).toEqual(fontWeights.normal.expectation);
});
});
7 changes: 7 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Configure Babel for Expo project with module resolution aliases.
* This function sets up Babel presets and plugins, including module resolution with aliases.
* @param {object} api - The Babel API object (optional, used for caching).
* @param {Function} api.cache - Function used for caching Babel configuration.
* @returns {object} Babel configuration object with presets and plugins.
*/
module.exports = function(api = { cache: () => {} }) {
api.cache(true);
return {
Expand Down

0 comments on commit 92e6ee8

Please sign in to comment.