Skip to content

Commit

Permalink
Update Readme with new features
Browse files Browse the repository at this point in the history
- Add run.js file.
- Update examples.
  • Loading branch information
bwreid committed Jul 2, 2021
1 parent 634e2fa commit 98e8ef0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
"test": "jest --runInBand",
"watch": "jest --watch-all"
},
"keywords": [],
"author": "",
Expand Down
50 changes: 32 additions & 18 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,35 @@ To run the tests, you can run the following command from the command line. You w
npm test
```

This will run the test output.
This will run the test output once.

#### Run file

If you want to manually test out your file, you can do so by running the following command.

```
node run.js
```

Add any arguments you want to test after the filename. For example:

```
node run.js plus 10 9 8
```

The output will be printed to your terminal.

#### Test watcher

If you'd like, you can have the tests run constantly. This means that each time you save your file, your tests will re-run. To do so, you can run the following:

```
npm run watch
```

Follow the on-screen prompts to exit out of the constant runner.

#### Testing syntax

In order to simulate the command line, you'll see the following lines in the tests:

Expand Down Expand Up @@ -80,20 +108,6 @@ node index.js minus 10 5 1

**Command line**

```
node index.js plus 1
```

**Result**

```js
1;
```

#### Example 4

**Command line**

```
node index.js divide 10 2
```
Expand All @@ -104,7 +118,7 @@ node index.js divide 10 2
"Invalid operation: divide";
```

#### Example 5
#### Example 4

**Command line**

Expand All @@ -118,7 +132,7 @@ node index.js minus
"No numbers provided...";
```

#### Example 6
#### Example 5

**Command line**

Expand All @@ -136,4 +150,4 @@ node index.js

- Remember that the first and second elements of `process.argv` are always the path to the `node` program and the filepath.
- Remember that each argument from the command line will be read in as a string. You will need some way to convert the inputs from strings to numbers.
- Because you don't know how many numbers will be passed in, you'll may need to _iterate_ over the numbers.
- Because you don't know how many numbers will be passed in, you may need to _iterate_ over the numbers.
3 changes: 3 additions & 0 deletions run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const calculator = require("./");
const result = calculator();
console.log(result);

0 comments on commit 98e8ef0

Please sign in to comment.