Skip to content

Commit 2071f24

Browse files
fix: documentation and contribution guide (#2)
* test: add test for asserting on sub-proxy object * fix: rm command on windows * feat: add node 10 to supported engines * ci: add commit_lint workflow and contribution guide * fix: commit_lint workflow * fix: commit_lint ci command * fix: remove commit_lint * docs: add installation and importing section of readme
1 parent 35f9957 commit 2071f24

File tree

4 files changed

+91
-3
lines changed

4 files changed

+91
-3
lines changed

CONTRIBUTING.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Contributing
2+
3+
## Reporting issues or suggesting features
4+
5+
- First [search the open issues](https://github.com/CreativeTechGuy/recursive-proxy-mock/issues) to see if someone has already created a similar issue
6+
- If you find an existing issue, sit tight. Please do not comment just to say "+1" or "me too".
7+
- If your issue is unique, [file a new issue here](https://github.com/CreativeTechGuy/recursive-proxy-mock/issues/new/choose).
8+
9+
## Getting started
10+
11+
**BEFORE YOU START**: Please create an issue that documents your change before you submit a PR.
12+
13+
1. Fork the repository
14+
1. Install dependencies by running `npm install`
15+
1. Run `npm run release` to ensure the package builds successfully without any changes
16+
1. Write the code for your feature/fix
17+
1. Write tests for the change - ensuring that every code branch is effectively tested
18+
1. Update the documentation as necessary
19+
1. Run `npm run release` before committing to ensure the code passes all tests/linters/etc
20+
1. Commit your changes following the [Commit message conventions](#commit-message-conventions) below
21+
1. Submit a PR for review
22+
23+
## Commit message conventions
24+
25+
We are following the Conventional Commits format as popularized by [the Angular commit format](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format). This is enforced by [commitlint](https://github.com/conventional-changelog/commitlint) and used to automatically publish new versions with [semantic-release](https://github.com/semantic-release/semantic-release).
26+
27+
At a minimum, every commit message should include following:
28+
29+
```
30+
<type>: <short summary>
31+
```
32+
33+
You can optionally include a body or footer if there's additional information that's important to add to the commit message:
34+
35+
```
36+
<type>: <short summary>
37+
<BLANK LINE>
38+
<body>
39+
<BLANK LINE>
40+
<footer>
41+
```
42+
43+
### type
44+
45+
Must be one of the following:
46+
47+
- `fix`: Bug fix (PATCH version)
48+
- `perf`: Performance improvement (PATCH version)
49+
- `feat`: New feature (MINOR version)
50+
- `refactor`: Changes source code without affecting functionality in any way (no new version)
51+
- `docs`: Update documentation only (no new version)
52+
- `test`: Add/update/fix test (no new version)
53+
54+
### short summary
55+
56+
A brief description of the change. Use the imperative, present tense: "fix" not "fixed" nor "fixes".
57+
58+
### body
59+
60+
Additional information to expand on the short summary
61+
62+
### footer
63+
64+
If the change is a breaking change, be sure to start this section with `BREAKING CHANGE: <breaking change summary>` and go on to summarize the migration instructions.

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Table of Contents
88

99
- [About](#about)
10+
- [Installation & Importing](#installation--importing)
1011
- [Examples](#examples)
1112
- [Use the mock to do literally anything](#use-the-mock-to-do-literally-anything)
1213
- [Override the default proxy behavior with custom values](#override-the-default-proxy-behavior-with-custom-values)
@@ -33,6 +34,20 @@ Have you ever wanted to mock something that has lots of nested properties and fu
3334

3435
Recursive Proxy Mock is a [JavaScript Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) that can handle literally anything. This is best explained with examples. Read on!
3536

37+
## Installation & Importing
38+
39+
```sh
40+
npm install --save-dev recursive-proxy-mock
41+
```
42+
43+
```js
44+
import { recursiveProxyMock } from "recursive-proxy-mock";
45+
```
46+
47+
```js
48+
const { recursiveProxyMock } = require("recursive-proxy-mock");
49+
```
50+
3651
## Examples
3752

3853
### Use the mock to do literally anything

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
"url": "https://github.com/CreativeTechGuy/recursive-proxy-mock.git"
3030
},
3131
"engines": {
32-
"node": ">=12"
32+
"node": ">=10"
3333
},
3434
"scripts": {
3535
"release": "npm run lint && npm run format:check && npm run spellcheck && npm run test && npm run build",
36-
"build": "rm -rf dist && rollup -c",
36+
"build": "rimraf dist && rollup -c",
3737
"lint": "eslint . --max-warnings 0",
3838
"lint:fix": "npm run lint -- --fix",
3939
"test": "jest",
@@ -43,7 +43,7 @@
4343
"spellcheck": "cspell \"**/*.{js,ts,json,md}\"",
4444
"list-outdated-dependencies": "npm-check-updates --format repo",
4545
"update-dependencies": "npm-check-updates -u && npm install && npm run build",
46-
"clean": "rm -rf node_modules coverage dist",
46+
"clean": "rimraf coverage dist node_modules || echo Repo cleaned",
4747
"readme-toc": "remark README.md --output --use \"toc=tight:true\" && prettier README.md --write",
4848
"prepare": "husky install"
4949
},
@@ -72,6 +72,7 @@
7272
"prettier": "^2.3.2",
7373
"remark-cli": "^10.0.0",
7474
"remark-toc": "^8.0.0",
75+
"rimraf": "^3.0.2",
7576
"rollup": "^2.56.1",
7677
"semantic-release": "^17.4.4",
7778
"ttypescript": "^1.5.12",

src/hasPathBeenVisited/hasPathBeenVisited.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@ describe("hasPathBeenVisited", () => {
2424
proxy.a;
2525
expect(hasPathBeenVisited(proxy, ["b", "c"])).toStrictEqual(false);
2626
});
27+
28+
test("returns false when passed a sub-mock object", () => {
29+
const proxy = recursiveProxyMock();
30+
const b = proxy.a.b;
31+
b.c.d;
32+
expect(hasPathBeenVisited(b, ["c", "d"])).toStrictEqual(false);
33+
expect(hasPathBeenVisited(proxy, ["a", "b", "c", "d"])).toStrictEqual(true);
34+
});
2735
});

0 commit comments

Comments
 (0)