From 3f1d2c628551d3634a0bae897ae216d8de518e03 Mon Sep 17 00:00:00 2001 From: Nahuel Garbezza Date: Tue, 8 Oct 2019 23:57:03 -0300 Subject: [PATCH 1/5] :construction-worker: add github action to automatically publish new releases to NPM and GPR --- .github/workflows/npmpublish.yml | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/npmpublish.yml diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml new file mode 100644 index 00000000..98ac570a --- /dev/null +++ b/.github/workflows/npmpublish.yml @@ -0,0 +1,44 @@ +name: Node.js Package + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 12 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 12 + registry-url: https://registry.npmjs.org/ + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + + publish-gpr: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 12 + registry-url: https://npm.pkg.github.com/ + scope: '@ngarbezza' + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GPR_TOKEN}} From 68ba7afc1ad55de1e99d8981a5cb36b02dda58f9 Mon Sep 17 00:00:00 2001 From: Nahuel Garbezza Date: Wed, 9 Oct 2019 00:03:12 -0300 Subject: [PATCH 2/5] :sparkles: add doesNotInclude() matcher (fixes #38) --- README.md | 1 + lib/asserter.js | 6 ++++++ lib/translations.js | 2 ++ tests/core/asserter_test.js | 14 ++++++++++++++ 4 files changed, 23 insertions(+) diff --git a/README.md b/README.md index fc2b5769..eefb1796 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ In this case, make sure suites don't have the `run()` at the end, otherwise they * `assert.that(() => { ... }).doesNotRaiseAnyErrors()` * Array inclusion: * `assert.that(collection).includes(object)` + * `assert.that(collection).doesNotInclude(object)` * `assert.that(collection).includesExactly(...objects)` * Emptiness * `assert.that(arrayOrString).isEmpty()` diff --git a/lib/asserter.js b/lib/asserter.js index 18613028..d272b779 100644 --- a/lib/asserter.js +++ b/lib/asserter.js @@ -88,6 +88,12 @@ class Assertion extends TestResultReporter { this._reportAssertionResult(resultIsSuccessful, failureMessage); } + doesNotInclude(object) { + const resultIsSuccessful = !this._actual.includes(object); + const failureMessage = `${this.translated('not_include')} ${object}`; + this._reportAssertionResult(resultIsSuccessful, failureMessage); + } + includesExactly(...objects) { const resultIsSuccessful = this._checkCollectionsHaveSameElements(this._actual, objects); const failureMessage = `${this.translated('include_exactly')} ${this._prettyPrint(objects)}`; diff --git a/lib/translations.js b/lib/translations.js index fe54446d..723c060c 100644 --- a/lib/translations.js +++ b/lib/translations.js @@ -28,6 +28,7 @@ const TRANSLATIONS = { be_true: 'be true', be_false: 'be false', include: 'include', + not_include: 'not include', include_exactly: 'include exactly', be_empty: 'be empty', be_not_empty: 'be not empty', @@ -63,6 +64,7 @@ const TRANSLATIONS = { be_true: 'sea true', be_false: 'sea false', include: 'incluya a', + not_include: 'no incluya a', include_exactly: 'incluya exactamente a', be_empty: 'sea vacío', be_not_empty: 'no sea vacío', diff --git a/tests/core/asserter_test.js b/tests/core/asserter_test.js index 5bddff13..b2054c18 100644 --- a/tests/core/asserter_test.js +++ b/tests/core/asserter_test.js @@ -141,6 +141,20 @@ suite('assertions behavior', () => { expectFailDueTo("Expected [] to include hey"); }); + // Collection assertions - doesNotInclude() + + test('doesNotInclude fails if the object is in the array', () => { + asserter.that(['hey']).doesNotInclude('hey'); + + expectFailDueTo("Expected [ 'hey' ] to not include hey"); + }); + + test('doesNotInclude passes if the object is not an array', () => { + asserter.that([]).doesNotInclude('hey'); + + expectSuccess(); + }); + // Collection assertions - includesExactly() test('includesExactly passes with a single object included', () => { From 25d0d6ee6251494c063e50fdf35c821c77322480 Mon Sep 17 00:00:00 2001 From: Nahuel Garbezza Date: Wed, 9 Oct 2019 09:13:54 -0300 Subject: [PATCH 3/5] :pencil: update CONTRIBUTING section according to current git workflow --- CONTRIBUTING.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d94f0ed9..409d3b7a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,13 @@ Issues and Pull Requests are welcome. Please follow the issue templates that are already configured. Have in mind the "Why" section (simplicity, OO code with good practices). +* Base branch: `develop`. Please open PRs against `develop`. +* Not mandatory, but nice to have, use [Gitmoji](https://gitmoji.carloscuesta.me) for tagging the type of commits you're adding. + If you add a new feature, please add: * an example for it on the `tests/examples` folder * unit tests for it on the `tests/core` folder +* an entry in the README explaining how to use it + +If you fix a bug, please add: +* unit tests for it on the `tests/core` folder From 2f1c125b5b43f255d5069f143cebf875c17af1a0 Mon Sep 17 00:00:00 2001 From: Nahuel Garbezza Date: Wed, 9 Oct 2019 09:14:23 -0300 Subject: [PATCH 4/5] :white_check_mark: add a unit test example for the doesNotInclude() matcher --- tests/examples/basic_assertions_test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/examples/basic_assertions_test.js b/tests/examples/basic_assertions_test.js index 2276d5b4..ed8c68ca 100644 --- a/tests/examples/basic_assertions_test.js +++ b/tests/examples/basic_assertions_test.js @@ -27,6 +27,8 @@ suite('testing testy - basic assertions', () => { test('inclusion in collection', () => assert.that([1, 2, 3]).includes(2)); + test('not inclusion in collection', () => assert.that([1, 2, 3]).doesNotInclude(4)); + test('inclusion of all elements in collection', () => { assert.that([1, 2, 3]).includesExactly(2, 3, 1); }); From de58e391fefcd97301ee314a41e7d112bec5eebb Mon Sep 17 00:00:00 2001 From: Nahuel Garbezza Date: Wed, 9 Oct 2019 09:16:50 -0300 Subject: [PATCH 5/5] :bookmark: release v4.2.0 --- CHANGELOG.md | 6 ++++++ package-lock.json | 2 +- package.json | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52df86ea..dc2402ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +Everything is released. Yay! :tada: + +## [4.2.0] - 2019-10-09 + ### Added * [Allow to pass a regex to the raises() matcher](https://github.com/ngarbezza/testy/issues/39) +* [New matcher: doesNotInclude()](https://github.com/ngarbezza/testy/issues/38) ### Fixed * [Poor error message when custom equality method is not found](https://github.com/ngarbezza/testy/issues/35): Thank you, [@TomerPacific](https://github.com/@TomerPacific)! @@ -93,6 +98,7 @@ readable and extensible. It also includes a huge internal refactor to make the t - Fix passed count at test runner level (no reported issue) [Unreleased]: https://github.com/ngarbezza/testy/compare/v4.1.1...HEAD +[4.2.0]: https://github.com/ngarbezza/testy/compare/v4.1.1...v4.2.0 [4.1.1]: https://github.com/ngarbezza/testy/compare/v4.0.1...v4.1.1 [4.0.1]: https://github.com/ngarbezza/testy/compare/v4.0.0...v4.0.1 [4.0.0]: https://github.com/ngarbezza/testy/compare/v3.1.1...v4.0.0 diff --git a/package-lock.json b/package-lock.json index 7b8a4077..0344096f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { "name": "@pmoo/testy", - "version": "4.1.1", + "version": "4.2.0", "lockfileVersion": 1 } diff --git a/package.json b/package.json index b41bb334..7e30ab4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pmoo/testy", - "version": "4.1.1", + "version": "4.2.0", "description": "A very simple testing library, for educational purposes", "homepage": "https://ngarbezza.github.io/testy/", "repository": { @@ -19,9 +19,11 @@ "lib": "./lib" }, "keywords": [ + "unit-test", "testing", "tdd", "simple", + "learning", "teaching", "oop" ],