Skip to content

Commit

Permalink
Merge pull request goldbergyoni#95 from dubzzz/fast-check
Browse files Browse the repository at this point in the history
Suggestion: switch to fast-check in examples for property based
  • Loading branch information
goldbergyoni authored Dec 16, 2019
2 parents aa2f08b + 6317cc1 commit b8ed2af
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 37 deletions.
24 changes: 12 additions & 12 deletions readme-zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,25 +441,25 @@ it("Better: When adding new valid product, get successful confirmation", async (

<br/>

### :clap: 正例: 使用“mocha-testcheck”测试输入的组合
### :clap: 正例: 使用“fast-check”测试输入的组合

![](https://img.shields.io/badge/🔧%20Example%20using%20Mocha-blue.svg
![](https://img.shields.io/badge/🔧%20Example%20using%20Jest-blue.svg
"Examples with Jest")

```javascript
require('mocha-testcheck').install();
const {expect} = require('chai');
import fc from "fast-check";

describe('Product service', () => {
describe('Adding new', () => {
describe("Product service", () => {
describe("Adding new", () => {
//this will run 100 times with different random properties
check.it('Add new product with random yet valid properties, always successful',
gen.int, gen.string, (id, name) => {
expect(addNewProduct(id, name).status).to.equal('approved');
});
})
it("Add new product with random yet valid properties, always successful", () =>
fc.assert(
fc.property(fc.integer(), fc.string(), (id, name) => {
expect(addNewProduct(id, name).status).toEqual("approved");
})
));
});
});

```

</details>
Expand Down
27 changes: 14 additions & 13 deletions readme.kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,23 +419,24 @@ it("더 나은 것: 유효한 제품이 추가된다면, 성공을 얻는다.",

<br/>

### :clap: 올바른 예: “mocha-testcheck”를 사용하여 다양한 인풋 조합으로 테스트 하십시오.
### :clap: 올바른 예: “fast-check”를 사용하여 다양한 인풋 조합으로 테스트 하십시오.

![](https://img.shields.io/badge/🔧%20Example%20using%20Mocha-blue.svg
![](https://img.shields.io/badge/🔧%20Example%20using%20Jest-blue.svg
"Examples with Jest")

```javascript
require('mocha-testcheck').install();
const {expect} = require('chai');

describe('Product service', () => {
describe('Adding new', () => {
//서로 다른 무작위 값으로 100회 호출됩니다.
check.it('Add new product with random yet valid properties, always successful',
gen.int, gen.string, (id, name) => {
expect(addNewProduct(id, name).status).to.equal('approved');
});
})
import fc from "fast-check";

describe("Product service", () => {
describe("Adding new", () => {
//서로 다른 무작위 값으로 100회 호출됩니다.
it("Add new product with random yet valid properties, always successful", () =>
fc.assert(
fc.property(fc.integer(), fc.string(), (id, name) => {
expect(addNewProduct(id, name).status).toEqual("approved");
})
));
});
});
```

Expand Down
24 changes: 12 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,25 +451,25 @@ it("Better: When adding new valid product, get successful confirmation", async (

<br/>

### :clap: Doing It Right Example: Testing many input permutations with “mocha-testcheck
### :clap: Doing It Right Example: Testing many input permutations with “fast-check

![](https://img.shields.io/badge/🔧%20Example%20using%20Mocha-blue.svg
![](https://img.shields.io/badge/🔧%20Example%20using%20Jest-blue.svg
"Examples with Jest")

```javascript
require('mocha-testcheck').install();
const {expect} = require('chai');
import fc from "fast-check";

describe('Product service', () => {
describe('Adding new', () => {
describe("Product service", () => {
describe("Adding new", () => {
//this will run 100 times with different random properties
check.it('Add new product with random yet valid properties, always successful',
gen.int, gen.string, (id, name) => {
expect(addNewProduct(id, name).status).to.equal('approved');
});
})
it("Add new product with random yet valid properties, always successful", () =>
fc.assert(
fc.property(fc.integer(), fc.string(), (id, name) => {
expect(addNewProduct(id, name).status).toEqual("approved");
})
));
});
});

```

</details>
Expand Down

0 comments on commit b8ed2af

Please sign in to comment.