Skip to content

Commit

Permalink
Merge pull request #213 from kwonoj/fix-max-frame
Browse files Browse the repository at this point in the history
fix(create): relate maxframevalue to frametimefactor
  • Loading branch information
kwonoj authored Jun 23, 2019
2 parents 0894f59 + bf02d6e commit cb8bdbc
Show file tree
Hide file tree
Showing 8 changed files with 1,018 additions and 1,335 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="1.0.3"></a>
## [1.0.3](https://github.com/kwonoj/rx-sandbox/compare/v1.0.2...v1.0.3) (2019-06-23)


### Bug Fixes

* **create:** relate maxframevalue to frametimefactor ([81587e8](https://github.com/kwonoj/rx-sandbox/commit/81587e8))



<a name="1.0.2"></a>
## [1.0.2](https://github.com/kwonoj/rx-sandbox/compare/v1.0.1...v1.0.2) (2019-01-10)

Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,13 @@ it('testcase', () => {
### Creating sandbox

```typescript
rxSandbox.create(autoFlush?: boolean, frameTimeFactor?: number): RxSandboxInstance
rxSandbox.create(autoFlush?: boolean, frameTimeFactor?: number, maxFrameValue?: number): RxSandboxInstance
```

Optional parameter values will be described further.
`frameTimeFactor` allows to override default frame passage `1` to given value.
`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)

Refer below for `autoFlush` option.

### Using RxSandboxInstance

Expand Down
2,280 changes: 964 additions & 1,316 deletions package-lock.json

Large diffs are not rendered by default.

29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rx-sandbox",
"version": "1.0.2",
"version": "1.0.3",
"description": "Marble diagram DSL based test suite for RxJS 6",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
Expand All @@ -23,7 +23,7 @@
"scripts": {
"prepublishOnly": "npm run build",
"test": "jest --config jest.json --coverage",
"lint": "tslint --type-check -c tslint.json -p tsconfig.json \"src/**/*.ts\" \"spec/**/*.ts\"",
"lint": "tslint -c tslint.json -p tsconfig.json \"src/**/*.ts\" \"spec/**/*.ts\"",
"lint:staged": "lint-staged",
"build": "npm-run-all build:clean && tsc",
"build:clean": "shx rm -rf ./dist",
Expand Down Expand Up @@ -53,34 +53,35 @@
},
"homepage": "https://github.com/kwonoj/rx-sandbox#readme",
"devDependencies": {
"@commitlint/cli": "^7.2.1",
"@commitlint/cli": "^8.0.0",
"@commitlint/config-angular": "^8.0.0",
"@types/chai": "^4.1.7",
"@types/jest": "^24.0.13",
"@types/jest": "^24.0.15",
"@types/node": "^12.0.10",
"chai": "^4.2.0",
"commitizen": "^3.0.5",
"conventional-changelog-cli": "^2.0.11",
"commitizen": "^3.1.1",
"conventional-changelog-cli": "^2.0.21",
"cz-conventional-changelog": "2.1.0",
"husky": "^2.3.0",
"husky": "^2.4.1",
"jest": "^24.8.0",
"jest-spin-reporter": "^1.0.2",
"lint-staged": "^8.1.0",
"lint-staged": "^8.2.1",
"npm-run-all": "^4.1.5",
"prettier": "^1.15.3",
"rxjs": "^6.3.3",
"prettier": "^1.18.2",
"rxjs": "^6.5.2",
"shx": "^0.3.2",
"ts-jest": "^24.0.2",
"tslint": "^5.12.0",
"tslint": "^5.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^3.5.1"
"typescript": "^3.5.2"
},
"peerDependencies": {
"rxjs": "6.x"
},
"dependencies": {
"jest-matcher-utils": "^24.0.0",
"jest-matcher-utils": "^24.8.0",
"jest-matchers": "^20.0.3",
"tslib": "^1.9.3"
"tslib": "^1.10.0"
},
"husky": {
"hooks": {
Expand Down
22 changes: 22 additions & 0 deletions spec/index-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ describe('rxSandbox', () => {
expect(v).to.deep.equal(expected);
});

it('should allow specify frameTimeFactor', () => {
const sandbox = idx.rxSandbox;

const { hot, getMessages } = sandbox.create(true, 2, 8);
const source = hot('-a--b');
const expected = [idx.next(2, 'a')];

const v = getMessages(source.pipe(mapTo('a')));
expect(v).to.deep.equal(expected);
});

it('should allow specify maxFrameValue', () => {
const sandbox = idx.rxSandbox;

const { hot, getMessages } = sandbox.create(true, 1, 4);
const source = hot('--a--|');
const expected = [idx.next(2, 'a')];

const v = getMessages(source.pipe(mapTo('a')));
expect(v).to.deep.equal(expected);
});

it('should able to create instance with custom frame', () => {
const sandbox = idx.rxSandbox;

Expand Down
1 change: 0 additions & 1 deletion src/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
declare module 'jest-matcher-utils';
declare module 'jest-matchers/*';
2 changes: 1 addition & 1 deletion src/assert/marbleAssert.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';
import { toEqual } from 'jest-matchers/build/matchers';
import { SubscriptionLog } from 'rxjs/internal/testing/SubscriptionLog';
import { TestMessage } from '../message/TestMessage';
import { constructObservableMarble } from './constructObservableMarble';
import { constructSubscriptionMarble } from './constructSubscriptionMarble';
const { matcherHint, printExpected, printReceived } = require('jest-matcher-utils'); //tslint:disable-line:no-require-imports no-var-requires

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

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type marbleAssertion = typeof marbleAssert;

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

return {
scheduler,
Expand Down

0 comments on commit cb8bdbc

Please sign in to comment.