Skip to content

Commit

Permalink
Merge pull request #44 from ngarbezza/develop
Browse files Browse the repository at this point in the history
[release] v4.2.0
  • Loading branch information
ngarbezza authored Oct 9, 2019
2 parents 5e34408 + cf8cc20 commit cce2793
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 2 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
@@ -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}}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)!
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`
Expand Down
6 changes: 6 additions & 0 deletions lib/asserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`;
Expand Down
2 changes: 2 additions & 0 deletions lib/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -19,9 +19,11 @@
"lib": "./lib"
},
"keywords": [
"unit-test",
"testing",
"tdd",
"simple",
"learning",
"teaching",
"oop"
],
Expand Down
14 changes: 14 additions & 0 deletions tests/core/asserter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/examples/basic_assertions_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit cce2793

Please sign in to comment.