Skip to content

Commit

Permalink
2.0.0
Browse files Browse the repository at this point in the history
- Add getRealNow/getFakeNow
- Add getRealUptime/getFakeUptime
- Add getRealHrtime/getFakeHrtime
- Add getRealPerformanceNow/getFakePerformanceNow
- Export only mockExecution
- Add format with prettier task
- Prettier on markdown snippets
- Remove .vscode folder
- Show master branch build only
- Throw when createNano not called with positive numbers
- Fix tick/tickAbsolute mutating all time at once
Date, hrtime, uptime, performance have their own nano instance.
This way each feature can have its own internal time independent from others.
Currently all features starts with a nano at 0,0 for convenience so it makes no difference.
If, however, one day, Date.now() must not be in sync with process.uptime() it's now possible.
  • Loading branch information
Damien Maillard committed Nov 16, 2017
1 parent d4601c0 commit bc6ec8b
Show file tree
Hide file tree
Showing 16 changed files with 674 additions and 633 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 3,4 @@ dist
coverage
.nyc_output
coverage.lcov
.vscode
50 changes: 0 additions & 50 deletions .vscode/launch.json

This file was deleted.

54 changes: 0 additions & 54 deletions .vscode/runFromDist.js

This file was deleted.

3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

17 changes: 0 additions & 17 deletions .vscode/tasks.json

This file was deleted.

32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 1,28 @@
# micmac

[![npm](https://badge.fury.io/js/micmac.svg)](https://badge.fury.io/js/micmac)
[![build](https://travis-ci.org/dmail/micmac.svg)](http://travis-ci.org/dmail/micmac)
[![build](https://travis-ci.org/dmail/micmac.svg?branch=master)](http://travis-ci.org/dmail/micmac)
[![codecov](https://codecov.io/gh/dmail/micmac/branch/master/graph/badge.svg)](https://codecov.io/gh/dmail/micmac)

Mock most native way to execute JavaScript asynchonously to trigger them manually for testing.

## Example

```javascript
import {mockExecution} from 'micmac'

mocExecution(({tick}) => {
let called = false
setTimeout(() => {
called = true
}, 10)
if (called) {
throw new Error("called must be false because 10ms are not ellapsed")
}
tick(10)
if (called === false) {
throw new Error("called must be true because tick(10) simulates that 10ms had ellapsed")
}
import { mockExecution } from "micmac"

mockExecution(({ tick }) => {
let called = false
setTimeout(() => {
called = true
}, 10)
if (called) {
throw new Error("called must be false because 10ms are not ellapsed")
}
tick(10)
if (called === false) {
throw new Error("called must be true because tick(10) simulates that 10ms had ellapsed")
}
})
```

Expand Down
Loading

0 comments on commit bc6ec8b

Please sign in to comment.