Skip to content

Commit cb8bdbc

Browse files
authored
Merge pull request #213 from kwonoj/fix-max-frame
fix(create): relate maxframevalue to frametimefactor
2 parents 0894f59 + bf02d6e commit cb8bdbc

File tree

8 files changed

+1018
-1335
lines changed

8 files changed

+1018
-1335
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<a name="1.0.3"></a>
2+
## [1.0.3](https://github.com/kwonoj/rx-sandbox/compare/v1.0.2...v1.0.3) (2019-06-23)
3+
4+
5+
### Bug Fixes
6+
7+
* **create:** relate maxframevalue to frametimefactor ([81587e8](https://github.com/kwonoj/rx-sandbox/commit/81587e8))
8+
9+
10+
111
<a name="1.0.2"></a>
212
## [1.0.2](https://github.com/kwonoj/rx-sandbox/compare/v1.0.1...v1.0.2) (2019-01-10)
313

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,13 @@ it('testcase', () => {
121121
### Creating sandbox
122122

123123
```typescript
124-
rxSandbox.create(autoFlush?: boolean, frameTimeFactor?: number): RxSandboxInstance
124+
rxSandbox.create(autoFlush?: boolean, frameTimeFactor?: number, maxFrameValue?: number): RxSandboxInstance
125125
```
126126

127-
Optional parameter values will be described further.
127+
`frameTimeFactor` allows to override default frame passage `1` to given value.
128+
`maxFrameValue` allows to override maximum frame number testscheduler will accept. (`1000` by default). Maxframevalue is relavant to frameTimeFactor. (i.e if `frameTimeFactor = 2` and `maxFrameValue = 4`, `--` will represent max frame)
129+
130+
Refer below for `autoFlush` option.
128131

129132
### Using RxSandboxInstance
130133

package-lock.json

Lines changed: 964 additions & 1316 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rx-sandbox",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Marble diagram DSL based test suite for RxJS 6",
55
"main": "./dist/src/index.js",
66
"types": "./dist/src/index.d.ts",
@@ -23,7 +23,7 @@
2323
"scripts": {
2424
"prepublishOnly": "npm run build",
2525
"test": "jest --config jest.json --coverage",
26-
"lint": "tslint --type-check -c tslint.json -p tsconfig.json \"src/**/*.ts\" \"spec/**/*.ts\"",
26+
"lint": "tslint -c tslint.json -p tsconfig.json \"src/**/*.ts\" \"spec/**/*.ts\"",
2727
"lint:staged": "lint-staged",
2828
"build": "npm-run-all build:clean && tsc",
2929
"build:clean": "shx rm -rf ./dist",
@@ -53,34 +53,35 @@
5353
},
5454
"homepage": "https://github.com/kwonoj/rx-sandbox#readme",
5555
"devDependencies": {
56-
"@commitlint/cli": "^7.2.1",
56+
"@commitlint/cli": "^8.0.0",
5757
"@commitlint/config-angular": "^8.0.0",
5858
"@types/chai": "^4.1.7",
59-
"@types/jest": "^24.0.13",
59+
"@types/jest": "^24.0.15",
60+
"@types/node": "^12.0.10",
6061
"chai": "^4.2.0",
61-
"commitizen": "^3.0.5",
62-
"conventional-changelog-cli": "^2.0.11",
62+
"commitizen": "^3.1.1",
63+
"conventional-changelog-cli": "^2.0.21",
6364
"cz-conventional-changelog": "2.1.0",
64-
"husky": "^2.3.0",
65+
"husky": "^2.4.1",
6566
"jest": "^24.8.0",
6667
"jest-spin-reporter": "^1.0.2",
67-
"lint-staged": "^8.1.0",
68+
"lint-staged": "^8.2.1",
6869
"npm-run-all": "^4.1.5",
69-
"prettier": "^1.15.3",
70-
"rxjs": "^6.3.3",
70+
"prettier": "^1.18.2",
71+
"rxjs": "^6.5.2",
7172
"shx": "^0.3.2",
7273
"ts-jest": "^24.0.2",
73-
"tslint": "^5.12.0",
74+
"tslint": "^5.18.0",
7475
"tslint-no-unused-expression-chai": "^0.1.4",
75-
"typescript": "^3.5.1"
76+
"typescript": "^3.5.2"
7677
},
7778
"peerDependencies": {
7879
"rxjs": "6.x"
7980
},
8081
"dependencies": {
81-
"jest-matcher-utils": "^24.0.0",
82+
"jest-matcher-utils": "^24.8.0",
8283
"jest-matchers": "^20.0.3",
83-
"tslib": "^1.9.3"
84+
"tslib": "^1.10.0"
8485
},
8586
"husky": {
8687
"hooks": {

spec/index-spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@ describe('rxSandbox', () => {
2727
expect(v).to.deep.equal(expected);
2828
});
2929

30+
it('should allow specify frameTimeFactor', () => {
31+
const sandbox = idx.rxSandbox;
32+
33+
const { hot, getMessages } = sandbox.create(true, 2, 8);
34+
const source = hot('-a--b');
35+
const expected = [idx.next(2, 'a')];
36+
37+
const v = getMessages(source.pipe(mapTo('a')));
38+
expect(v).to.deep.equal(expected);
39+
});
40+
41+
it('should allow specify maxFrameValue', () => {
42+
const sandbox = idx.rxSandbox;
43+
44+
const { hot, getMessages } = sandbox.create(true, 1, 4);
45+
const source = hot('--a--|');
46+
const expected = [idx.next(2, 'a')];
47+
48+
const v = getMessages(source.pipe(mapTo('a')));
49+
expect(v).to.deep.equal(expected);
50+
});
51+
3052
it('should able to create instance with custom frame', () => {
3153
const sandbox = idx.rxSandbox;
3254

src/ambient.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
declare module 'jest-matcher-utils';
21
declare module 'jest-matchers/*';

src/assert/marbleAssert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';
21
import { toEqual } from 'jest-matchers/build/matchers';
32
import { SubscriptionLog } from 'rxjs/internal/testing/SubscriptionLog';
43
import { TestMessage } from '../message/TestMessage';
54
import { constructObservableMarble } from './constructObservableMarble';
65
import { constructSubscriptionMarble } from './constructSubscriptionMarble';
6+
const { matcherHint, printExpected, printReceived } = require('jest-matcher-utils'); //tslint:disable-line:no-require-imports no-var-requires
77

88
const toEqualAssert = toEqual.bind({ expand: false });
99

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type marbleAssertion = typeof marbleAssert;
2828

2929
const rxSandbox: RxSandbox = {
3030
create: (autoFlush: boolean = false, frameTimeFactor: number = 1, maxFrameValue = 1000) => {
31-
const scheduler = new TestScheduler(autoFlush, frameTimeFactor, maxFrameValue);
31+
const scheduler = new TestScheduler(autoFlush, frameTimeFactor, Math.round(maxFrameValue / frameTimeFactor));
3232

3333
return {
3434
scheduler,

0 commit comments

Comments
 (0)