Skip to content

Commit

Permalink
Bump version and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
amobiz committed Feb 21, 2019
1 parent c8f5bfb commit ba162db
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 amobiz
Copyright (c) 2019 amobiz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
53 changes: 50 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var cases = [{

var options = {
errback: true, // is all test defaults to errback?
prefix: '' // prefix to test names
prefix: '' // prefix to test names
};

function runner(value, options, done) { // errback runner takes a `done` callback
Expand All @@ -56,6 +56,9 @@ describe('module: mocha-cases', function () {
Default pass through runner will be used if no runner provided at all.

### One case vs. multiple values vs. one expected

You can use an array of `values` with a single `expected` value:

``` javascript
describe('prime number', function () {
test({
Expand All @@ -67,6 +70,9 @@ describe('prime number', function () {
```

### One case vs. multiple values vs. multiple expected

You can use an array of `values` and an array of `expected` values, to pair multiple given values and expected values:

``` javascript
describe('prime number', function () {
test({
Expand All @@ -78,7 +84,43 @@ describe('prime number', function () {
});
```

#### or
Or, you can use `cases` to specify multiple cases:

``` javascript
describe('prime number', function () {
test({
name: 'isPrime({value}) should be {expected}',
cases: [{
value: 2,
expected: true
}, {
value: 3,
expected: true
}, {
value: 4,
expected: false
}, {
value: 5,
expected: true
}, {
value: 6,
expected: false
}, {
value: 7,
expected: true
}, {
value: 8,
expected: false
}, {
value: 9,
expected: false
}],
runner: isPrime
});
});
```

If your values are simple enougth, you may want to simplify them with a pair of value / expected value for each case:

``` javascript
describe('prime number', function () {
Expand All @@ -93,7 +135,7 @@ describe('prime number', function () {
[7, true],
[8, false],
[9, false]
]
],
runner: isPrime
});
});
Expand All @@ -112,6 +154,11 @@ $ npm test

## Change Logs

* 2019/02/22 - 0.3.0

* Feature: Allow escaping the brace characters `{` and `}` with `\\`.
* Feature: Allow entries of `cases` be an object.

* 2018/01/23 - 0.2.1

* Feature: Accept function for test name
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mocha-cases",
"version": "0.2.1",
"version": "0.3.0",
"description": "A tiny mocha test case runner. Suited for simple input to output validation tests.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit ba162db

Please sign in to comment.