/take-home-test

Exercise for take-home activity. Tests created for existing drugs. Refactor Javascript code. Add new medicine.

Primary LanguageJavaScriptMIT LicenseMIT

📗 Table of Contents

📖 Take-home test

Take-home source

Inato Take-Home Test Specification

You are a new developer in the Inato team, and your first job is to add a feature to an old existing piece of code.

System specifications

Hi and welcome to the team. We are in the future, and Inato has extended its activities by opening a pharmacy. Your task is to add a new feature to our system so that we can begin distributing a new drug. First an introduction to our system:

  • All drugs have an expiresIn value which denotes the number of days we have until the item expires.
  • All drugs have a benefit value which denotes how powerful the drug is.
  • At the end of each day our system lowers both values for every drug

But there is more:

  • Once the expiration date has passed, Benefit degrades twice as fast.
  • The Benefit of an item is never negative.
  • "Herbal Tea" actually increases in Benefit the older it gets. Benefit increases twice as fast after the expiration date.
  • The Benefit of an item is never more than 50.
  • "Magic Pill" never expires nor decreases in Benefit.
  • "Fervex", like Herbal Tea, increases in Benefit as its expiration date approaches. Benefit increases by 2 when there are 10 days or less and by 3 when there are 5 days or less but Benefit drops to 0 after the expiration date.

We have recently signed a supplier of "Dafalgan". This requires an update to our system:

  • "Dafalgan" degrades in Benefit twice as fast as normal drugs.

Instructions

  • Clone this repository (do not fork it)
  • Implement the required feature
  • Publish it on your GitHub (or Gitlab, or whatever...)
  • Send us the link and tell us approximatively how much time you spent on this assignment

You are encouraged to refactor the existing code before adding your own, as you would do if this was a real task in real life. We strongly recommend that you write tests to help you during this process.

Feel free to make any changes to the updateBenefitValue method implementation and add any new code as long as everything still works correctly. However, do not break the public API of the Drug and Pharmacy classes, as those are used by other pieces of the software (you can add new methods though).

Please commit as frequently as possible to make the review easier.

Test

To make sure that you will not break anything in the existing code, we added the result of the simulation in the output.json file. Make sure that your code is able to generate a file with identical content. You can generate a new file by running one of the following commands:

yarn start
docker-compose up

🛠 Built With

Tech Stack

Client

Key Features

  • JEST tests

(back to top)

💻 Getting Started

To get a local copy up and running, follow these steps.

Prerequisites

In order to run this project you need:

Node.js

Setup

Clone this repository to your desired folder:

using HTTPS:

  git clone https://github.com/ElsonOtake/take-home-test.git
  cd take-home-test

using an SSH key:

  git clone git@github.com:ElsonOtake/take-home-test.git
  cd take-home-test

using GitHub CLI:

  git clone gh repo clone ElsonOtake/take-home-test
  cd take-home-test

Install

Install this project with:

  npm install

Usage

To run the project, execute the following command:

  npm start

Run tests

To run tests, run the following command:

  npm test

(back to top)

👥 Author

👤 Elson Otake

(back to top)

🔭 Future Features

  • Add more tests

(back to top)

🤝 Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page.

(back to top)

⭐️ Show your support

Give a ⭐️ if you like this project!

(back to top)

🙏 Acknowledgments

I would like to thank:

(back to top)

📝 License

This project is MIT licensed.

(back to top)