GithubHelp home page GithubHelp logo

nathanjreidy / react-calculator Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 497 KB

https://nathanjreidy.github.io/react-calculator/

Home Page: https://nathanjreidy.github.io/react-calculator/

Shell 1.91% HTML 9.20% JavaScript 84.68% CSS 4.21%

react-calculator's Introduction

React: Calculator

Environment

  • React Version: 16.13.1
  • Node Version: 12(LTS)
  • Default Port: 8000

Application Demo:

Functionality Requirements

  • There are 2 input boxes for entering values.

  • There are 4 buttons that perform mathematical operations to calculate the result:

    • + performs addition

    • - performs subtraction

    • * performs multiplication

    • / performs division

  • Whenever you click any of these 4 buttons, an operation is performed and result is calculated. This result is rendered in the following div - <div data-testid="result">Result: {result}</div>. Here {result} is the result calculated. This div should be rendered only when we have calculated some result. Initially, since no operation is performed, this div should not be rendered.

  • The label between the inputs displays the current operation. The initial operation to show in the label is '+'.

  • Maintain the total count of operations performed. The count is rendered in the following div - <div data-testid="total-operations">Total operations performed: {count}</div>. Here {count} is the total number of operations performed. Initially, this value should be 0.

  • There is a 'Reset' button, which, when clicked, clears the input boxes, sets the selected operator back to its default value '+', and clears the result value (thus not rendering the result div). It does not reset the total operations count.

Testing Requirements

The following data-testid attributes are required in the component for the tests to pass:

  • Total Operations div should have data-testid attribute 'total-operations'.

  • Input for first number should have data-testid attribute 'app-input1'.

  • Input for second number should have data-testid attribute 'app-input2'.

  • Label to show selected operator should have data-testid attribute 'selected-operator'.

  • Add button should have data-testid attribute 'addButton'.

  • Subtract button should have data-testid attribute 'subtractButton'.

  • Multiply button should have data-testid attribute 'multiplyButton'.

  • Divide button should have data-testid attribute 'divideButton'.

  • Result div should have data-testid attribute 'result'.

  • Reset button should have data-testid attribute 'resetButton'.

Please note that component has above data-testids for test cases and certain classes and ids for rendering purposes. It is advised not to change them.

Project Specifications

Read Only Files

  • src/App.test.js

Commands

  • run:
bash bin/env_setup && . $HOME/.nvm/nvm.sh && npm start
  • install:
bash bin/env_setup && . $HOME/.nvm/nvm.sh && npm install
  • test:
bash bin/env_setup && . $HOME/.nvm/nvm.sh && npm test

react-calculator's People

Contributors

nathanjreidy avatar

Stargazers

Hadj H. avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.