Skip to content

Commit

Permalink
fix: documentation and contribution guide (#2)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
CreativeTechGuy authored Aug 13, 2021
1 parent 35f9957 commit 2071f24
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 3 deletions.
64 changes: 64 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Contributing

## Reporting issues or suggesting features

- First [search the open issues](https://github.com/CreativeTechGuy/recursive-proxy-mock/issues) to see if someone has already created a similar issue
- If you find an existing issue, sit tight. Please do not comment just to say "+1" or "me too".
- If your issue is unique, [file a new issue here](https://github.com/CreativeTechGuy/recursive-proxy-mock/issues/new/choose).

## Getting started

**BEFORE YOU START**: Please create an issue that documents your change before you submit a PR.

1. Fork the repository
1. Install dependencies by running `npm install`
1. Run `npm run release` to ensure the package builds successfully without any changes
1. Write the code for your feature/fix
1. Write tests for the change - ensuring that every code branch is effectively tested
1. Update the documentation as necessary
1. Run `npm run release` before committing to ensure the code passes all tests/linters/etc
1. Commit your changes following the [Commit message conventions](#commit-message-conventions) below
1. Submit a PR for review

## Commit message conventions

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).

At a minimum, every commit message should include following:

```
<type>: <short summary>
```

You can optionally include a body or footer if there's additional information that's important to add to the commit message:

```
<type>: <short summary>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

### type

Must be one of the following:

- `fix`: Bug fix (PATCH version)
- `perf`: Performance improvement (PATCH version)
- `feat`: New feature (MINOR version)
- `refactor`: Changes source code without affecting functionality in any way (no new version)
- `docs`: Update documentation only (no new version)
- `test`: Add/update/fix test (no new version)

### short summary

A brief description of the change. Use the imperative, present tense: "fix" not "fixed" nor "fixes".

### body

Additional information to expand on the short summary

### footer

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.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Table of Contents

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

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!

## Installation & Importing

```sh
npm install --save-dev recursive-proxy-mock
```

```js
import { recursiveProxyMock } from "recursive-proxy-mock";
```

```js
const { recursiveProxyMock } = require("recursive-proxy-mock");
```

## Examples

### Use the mock to do literally anything
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"url": "https://github.com/CreativeTechGuy/recursive-proxy-mock.git"
},
"engines": {
"node": ">=12"
"node": ">=10"
},
"scripts": {
"release": "npm run lint && npm run format:check && npm run spellcheck && npm run test && npm run build",
"build": "rm -rf dist && rollup -c",
"build": "rimraf dist && rollup -c",
"lint": "eslint . --max-warnings 0",
"lint:fix": "npm run lint -- --fix",
"test": "jest",
Expand All @@ -43,7 +43,7 @@
"spellcheck": "cspell \"**/*.{js,ts,json,md}\"",
"list-outdated-dependencies": "npm-check-updates --format repo",
"update-dependencies": "npm-check-updates -u && npm install && npm run build",
"clean": "rm -rf node_modules coverage dist",
"clean": "rimraf coverage dist node_modules || echo Repo cleaned",
"readme-toc": "remark README.md --output --use \"toc=tight:true\" && prettier README.md --write",
"prepare": "husky install"
},
Expand Down Expand Up @@ -72,6 +72,7 @@
"prettier": "^2.3.2",
"remark-cli": "^10.0.0",
"remark-toc": "^8.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.56.1",
"semantic-release": "^17.4.4",
"ttypescript": "^1.5.12",
Expand Down
8 changes: 8 additions & 0 deletions src/hasPathBeenVisited/hasPathBeenVisited.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ describe("hasPathBeenVisited", () => {
proxy.a;
expect(hasPathBeenVisited(proxy, ["b", "c"])).toStrictEqual(false);
});

test("returns false when passed a sub-mock object", () => {
const proxy = recursiveProxyMock();
const b = proxy.a.b;
b.c.d;
expect(hasPathBeenVisited(b, ["c", "d"])).toStrictEqual(false);
expect(hasPathBeenVisited(proxy, ["a", "b", "c", "d"])).toStrictEqual(true);
});
});

0 comments on commit 2071f24

Please sign in to comment.