Skip to content

Commit b8ed2af

Browse files
authored
Merge pull request goldbergyoni#95 from dubzzz/fast-check
Suggestion: switch to fast-check in examples for property based
2 parents aa2f08b + 6317cc1 commit b8ed2af

File tree

3 files changed

+38
-37
lines changed

3 files changed

+38
-37
lines changed

readme-zh-CN.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -441,25 +441,25 @@ it("Better: When adding new valid product, get successful confirmation", async (
441441

442442
<br/>
443443

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

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

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

453-
describe('Product service', () => {
454-
describe('Adding new', () => {
452+
describe("Product service", () => {
453+
describe("Adding new", () => {
455454
//this will run 100 times with different random properties
456-
check.it('Add new product with random yet valid properties, always successful',
457-
gen.int, gen.string, (id, name) => {
458-
expect(addNewProduct(id, name).status).to.equal('approved');
459-
});
460-
})
455+
it("Add new product with random yet valid properties, always successful", () =>
456+
fc.assert(
457+
fc.property(fc.integer(), fc.string(), (id, name) => {
458+
expect(addNewProduct(id, name).status).toEqual("approved");
459+
})
460+
));
461+
});
461462
});
462-
463463
```
464464

465465
</details>

readme.kr.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -419,23 +419,24 @@ it("더 나은 것: 유효한 제품이 추가된다면, 성공을 얻는다.",
419419

420420
<br/>
421421

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

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

427427
```javascript
428-
require('mocha-testcheck').install();
429-
const {expect} = require('chai');
430-
431-
describe('Product service', () => {
432-
describe('Adding new', () => {
433-
//서로 다른 무작위 값으로 100회 호출됩니다.
434-
check.it('Add new product with random yet valid properties, always successful',
435-
gen.int, gen.string, (id, name) => {
436-
expect(addNewProduct(id, name).status).to.equal('approved');
437-
});
438-
})
428+
import fc from "fast-check";
429+
430+
describe("Product service", () => {
431+
describe("Adding new", () => {
432+
//서로 다른 무작위 값으로 100회 호출됩니다.
433+
it("Add new product with random yet valid properties, always successful", () =>
434+
fc.assert(
435+
fc.property(fc.integer(), fc.string(), (id, name) => {
436+
expect(addNewProduct(id, name).status).toEqual("approved");
437+
})
438+
));
439+
});
439440
});
440441
```
441442

readme.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -451,25 +451,25 @@ it("Better: When adding new valid product, get successful confirmation", async (
451451

452452
<br/>
453453

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

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

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

463-
describe('Product service', () => {
464-
describe('Adding new', () => {
462+
describe("Product service", () => {
463+
describe("Adding new", () => {
465464
//this will run 100 times with different random properties
466-
check.it('Add new product with random yet valid properties, always successful',
467-
gen.int, gen.string, (id, name) => {
468-
expect(addNewProduct(id, name).status).to.equal('approved');
469-
});
470-
})
465+
it("Add new product with random yet valid properties, always successful", () =>
466+
fc.assert(
467+
fc.property(fc.integer(), fc.string(), (id, name) => {
468+
expect(addNewProduct(id, name).status).toEqual("approved");
469+
})
470+
));
471+
});
471472
});
472-
473473
```
474474

475475
</details>

0 commit comments

Comments
 (0)