In the first section, I've detailed the approach I took to this project. You can find the project specifications derived below, and the points that have been completed.
Enter the command yarn test --coverage
in the terminal to run tests with coverage.
The first thing I observed is that the test case resolves based on arithmetic rules. Some basic calculators do not resolve as such, and thus evaluates every new number entered with the previous arithmetic operation. I've chosen to show the current math expression created so that the user can check easily.
Due to size of the feature, there isn't much to do. In order to demonstrate my understanding of Agile workflow, I've broken the individual tasks into "features".
As for my understanding of Gitflow workflow, I've created a release branch release/1.0.0
to make a new release from develop
to master
. I've also created a number of branches (which you can find in this project) to build the features required.
Since this is a test to evaluate my abilities, I avoided using the built-in eval
function and chose to build my own function to resolve arithmetic equations.
Personally, I like to isolate business logic with Redux Saga. Sagas can access reducer values, hence relegating actions to take inputs and reducers to storing values. Moreover, the ability to mock certain calls within Sagas and to trigger side effects makes a great case for testing and re-usability.
- Use the latest expo to create the project
- Use Redux
-
src
should only contain the following files.constants.js, actions.js, reducer.js, Button.js, Screen.js, styles.js
- Write styles.js without width / height key
- Write Button.js as React.memo without equal function and make sure it’s not re-rendering
- Pass given test case
1 + 2 - 3 * 4 = -9
- Each file is less than 60 lines
- Use regex
- More than 80% test coverage
- Reducer is larger than 60 lines, due to the calculations needed.
- Button has reduced coverage due to platform specific executions.
jest-expo
can cover more platforms, but it does not allow for inflating likeenzyme
.App.test.js
integration test is deemed as important to keep application integrity and hence I've decided to go withenzyme
instead.- In
setUp.js
, lines starting withWarning:
are suppressed due to a lack of support for React Native on Enzyme. The checks are for HTML elements and is too noisy in the console.