jasmine-marbles
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -226,5 +226,5 @@ (function (global, factory) { | ||
function deleteErrorNotificationStack(marble) { | ||
var notification = marble.notification; | ||
const { notification } = marble; | ||
if (notification) { | ||
var kind = notification.kind, exception = notification.exception; | ||
const { kind, exception } = notification; | ||
if (kind === 'E' && exception instanceof Error) { | ||
@@ -243,11 +243,11 @@ notification.exception = { | ||
expected = expected.map(deleteErrorNotificationStack); | ||
var passed = lodash.isEqual(actual, expected); | ||
const passed = lodash.isEqual(actual, expected); | ||
if (passed) { | ||
return; | ||
} | ||
var message_1 = '\nExpected \n'; | ||
actual.forEach(function (x) { return (message_1 += "\t" + stringify(x) + "\n"); }); | ||
message_1 += '\t\nto deep equal \n'; | ||
expected.forEach(function (x) { return (message_1 += "\t" + stringify(x) + "\n"); }); | ||
expect(passed).toEqual(message_1); | ||
let message = '\nExpected \n'; | ||
actual.forEach((x) => (message += `\t${stringify(x)}\n`)); | ||
message += '\t\nto deep equal \n'; | ||
expected.forEach((x) => (message += `\t${stringify(x)}\n`)); | ||
expect(passed).toEqual(message); | ||
} | ||
@@ -259,3 +259,3 @@ else { | ||
var scheduler; | ||
let scheduler; | ||
function initTestScheduler() { | ||
@@ -274,42 +274,26 @@ scheduler = new rxjs_testing.TestScheduler(observableMatcher); | ||
var __extends = (window && window.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var TestColdObservable = /** @class */ (function (_super) { | ||
__extends(TestColdObservable, _super); | ||
function TestColdObservable(marbles, values, error) { | ||
var _this = _super.call(this) || this; | ||
_this.marbles = marbles; | ||
_this.values = values; | ||
_this.error = error; | ||
_this.source = getTestScheduler().createColdObservable(marbles, values, error); | ||
return _this; | ||
class TestColdObservable extends rxjs.Observable { | ||
constructor(marbles, values, error) { | ||
super(); | ||
this.marbles = marbles; | ||
this.values = values; | ||
this.error = error; | ||
this.source = getTestScheduler().createColdObservable(marbles, values, error); | ||
} | ||
TestColdObservable.prototype.getSubscriptions = function () { | ||
getSubscriptions() { | ||
return this.source['subscriptions']; | ||
}; | ||
return TestColdObservable; | ||
}(rxjs.Observable)); | ||
var TestHotObservable = /** @class */ (function (_super) { | ||
__extends(TestHotObservable, _super); | ||
function TestHotObservable(marbles, values, error) { | ||
var _this = _super.call(this) || this; | ||
_this.marbles = marbles; | ||
_this.values = values; | ||
_this.error = error; | ||
_this.source = getTestScheduler().createHotObservable(marbles, values, error); | ||
return _this; | ||
} | ||
TestHotObservable.prototype.getSubscriptions = function () { | ||
} | ||
class TestHotObservable extends rxjs.Observable { | ||
constructor(marbles, values, error) { | ||
super(); | ||
this.marbles = marbles; | ||
this.values = values; | ||
this.error = error; | ||
this.source = getTestScheduler().createHotObservable(marbles, values, error); | ||
} | ||
getSubscriptions() { | ||
return this.source['subscriptions']; | ||
}; | ||
return TestHotObservable; | ||
}(rxjs.Observable)); | ||
} | ||
} | ||
@@ -331,18 +315,18 @@ function hot(marbles, values, error) { | ||
function materializeInnerObservable(observable, outerFrame) { | ||
var messages = []; | ||
var scheduler = getTestScheduler(); | ||
observable.subscribe(function (value) { | ||
const messages = []; | ||
const scheduler = getTestScheduler(); | ||
observable.subscribe(value => { | ||
messages.push({ | ||
frame: scheduler.frame - outerFrame, | ||
notification: rxjs.Notification.createNext(value) | ||
notification: rxjs.Notification.createNext(value), | ||
}); | ||
}, function (err) { | ||
}, err => { | ||
messages.push({ | ||
frame: scheduler.frame - outerFrame, | ||
notification: rxjs.Notification.createError(err) | ||
notification: rxjs.Notification.createError(err), | ||
}); | ||
}, function () { | ||
}, () => { | ||
messages.push({ | ||
frame: scheduler.frame - outerFrame, | ||
notification: rxjs.Notification.createComplete() | ||
notification: rxjs.Notification.createComplete(), | ||
}); | ||
@@ -354,20 +338,18 @@ }); | ||
jasmine.addMatchers({ | ||
toHaveSubscriptions: function () { return ({ | ||
toHaveSubscriptions: () => ({ | ||
compare: function (actual, marbles) { | ||
var marblesArray = typeof marbles === 'string' ? [marbles] : marbles; | ||
var results = marblesArray.map(function (marbles) { | ||
return rxjs_testing.TestScheduler.parseMarblesAsSubscriptions(marbles); | ||
}); | ||
const marblesArray = typeof marbles === 'string' ? [marbles] : marbles; | ||
const results = marblesArray.map(marbles => rxjs_testing.TestScheduler.parseMarblesAsSubscriptions(marbles)); | ||
expect(results).toEqual(actual.getSubscriptions()); | ||
return { pass: true }; | ||
} | ||
}); }, | ||
toBeObservable: function () { return ({ | ||
}, | ||
}), | ||
toBeObservable: () => ({ | ||
compare: function (actual, fixture) { | ||
var results = []; | ||
var subscription; | ||
var scheduler = getTestScheduler(); | ||
scheduler.schedule(function () { | ||
subscription = actual.subscribe(function (x) { | ||
var value = x; | ||
const results = []; | ||
let subscription; | ||
const scheduler = getTestScheduler(); | ||
scheduler.schedule(() => { | ||
subscription = actual.subscribe((x) => { | ||
let value = x; | ||
// Support Observable-of-Observables | ||
@@ -379,13 +361,13 @@ if (x instanceof rxjs.Observable) { | ||
frame: scheduler.frame, | ||
notification: rxjs.Notification.createNext(value) | ||
notification: rxjs.Notification.createNext(value), | ||
}); | ||
}, function (err) { | ||
}, (err) => { | ||
results.push({ | ||
frame: scheduler.frame, | ||
notification: rxjs.Notification.createError(err) | ||
notification: rxjs.Notification.createError(err), | ||
}); | ||
}, function () { | ||
}, () => { | ||
results.push({ | ||
frame: scheduler.frame, | ||
notification: rxjs.Notification.createComplete() | ||
notification: rxjs.Notification.createComplete(), | ||
}); | ||
@@ -395,13 +377,13 @@ }); | ||
scheduler.flush(); | ||
var expected = rxjs_testing.TestScheduler.parseMarbles(fixture.marbles, fixture.values, fixture.error, true); | ||
const expected = rxjs_testing.TestScheduler.parseMarbles(fixture.marbles, fixture.values, fixture.error, true); | ||
expect(results).toEqual(expected); | ||
return { pass: true }; | ||
} | ||
}); } | ||
}, | ||
}), | ||
}); | ||
} | ||
if (typeof module === 'object' && module.exports) { | ||
jasmine.getEnv().beforeAll(function () { return addMatchers(); }); | ||
jasmine.getEnv().beforeEach(function () { return initTestScheduler(); }); | ||
jasmine.getEnv().afterEach(function () { | ||
jasmine.getEnv().beforeAll(() => addMatchers()); | ||
jasmine.getEnv().beforeEach(() => initTestScheduler()); | ||
jasmine.getEnv().afterEach(() => { | ||
getTestScheduler().flush(); | ||
@@ -408,0 +390,0 @@ resetTestScheduler(); |
@@ -14,3 +14,3 @@ import { TestColdObservable, TestHotObservable } from './src/test-observables'; | ||
namespace jest { | ||
interface Matchers<T> { | ||
interface Matchers<R> { | ||
toBeObservable: any; | ||
@@ -17,0 +17,0 @@ toHaveSubscriptions: any; |
import { Notification, Observable } from 'rxjs'; | ||
import { TestScheduler } from 'rxjs/testing'; | ||
import { getTestScheduler, initTestScheduler, resetTestScheduler } from './src/scheduler'; | ||
import { TestColdObservable, TestHotObservable } from './src/test-observables'; | ||
export { getTestScheduler, initTestScheduler, resetTestScheduler } from './src/scheduler'; | ||
import { getTestScheduler, initTestScheduler, resetTestScheduler, } from './src/scheduler'; | ||
import { TestColdObservable, TestHotObservable, } from './src/test-observables'; | ||
export { getTestScheduler, initTestScheduler, resetTestScheduler, } from './src/scheduler'; | ||
export function hot(marbles, values, error) { | ||
@@ -21,18 +21,18 @@ return new TestHotObservable(marbles.trim(), values, error); | ||
function materializeInnerObservable(observable, outerFrame) { | ||
var messages = []; | ||
var scheduler = getTestScheduler(); | ||
observable.subscribe(function (value) { | ||
const messages = []; | ||
const scheduler = getTestScheduler(); | ||
observable.subscribe(value => { | ||
messages.push({ | ||
frame: scheduler.frame - outerFrame, | ||
notification: Notification.createNext(value) | ||
notification: Notification.createNext(value), | ||
}); | ||
}, function (err) { | ||
}, err => { | ||
messages.push({ | ||
frame: scheduler.frame - outerFrame, | ||
notification: Notification.createError(err) | ||
notification: Notification.createError(err), | ||
}); | ||
}, function () { | ||
}, () => { | ||
messages.push({ | ||
frame: scheduler.frame - outerFrame, | ||
notification: Notification.createComplete() | ||
notification: Notification.createComplete(), | ||
}); | ||
@@ -44,20 +44,18 @@ }); | ||
jasmine.addMatchers({ | ||
toHaveSubscriptions: function () { return ({ | ||
toHaveSubscriptions: () => ({ | ||
compare: function (actual, marbles) { | ||
var marblesArray = typeof marbles === 'string' ? [marbles] : marbles; | ||
var results = marblesArray.map(function (marbles) { | ||
return TestScheduler.parseMarblesAsSubscriptions(marbles); | ||
}); | ||
const marblesArray = typeof marbles === 'string' ? [marbles] : marbles; | ||
const results = marblesArray.map(marbles => TestScheduler.parseMarblesAsSubscriptions(marbles)); | ||
expect(results).toEqual(actual.getSubscriptions()); | ||
return { pass: true }; | ||
} | ||
}); }, | ||
toBeObservable: function () { return ({ | ||
}, | ||
}), | ||
toBeObservable: () => ({ | ||
compare: function (actual, fixture) { | ||
var results = []; | ||
var subscription; | ||
var scheduler = getTestScheduler(); | ||
scheduler.schedule(function () { | ||
subscription = actual.subscribe(function (x) { | ||
var value = x; | ||
const results = []; | ||
let subscription; | ||
const scheduler = getTestScheduler(); | ||
scheduler.schedule(() => { | ||
subscription = actual.subscribe((x) => { | ||
let value = x; | ||
// Support Observable-of-Observables | ||
@@ -69,13 +67,13 @@ if (x instanceof Observable) { | ||
frame: scheduler.frame, | ||
notification: Notification.createNext(value) | ||
notification: Notification.createNext(value), | ||
}); | ||
}, function (err) { | ||
}, (err) => { | ||
results.push({ | ||
frame: scheduler.frame, | ||
notification: Notification.createError(err) | ||
notification: Notification.createError(err), | ||
}); | ||
}, function () { | ||
}, () => { | ||
results.push({ | ||
frame: scheduler.frame, | ||
notification: Notification.createComplete() | ||
notification: Notification.createComplete(), | ||
}); | ||
@@ -85,13 +83,13 @@ }); | ||
scheduler.flush(); | ||
var expected = TestScheduler.parseMarbles(fixture.marbles, fixture.values, fixture.error, true); | ||
const expected = TestScheduler.parseMarbles(fixture.marbles, fixture.values, fixture.error, true); | ||
expect(results).toEqual(expected); | ||
return { pass: true }; | ||
} | ||
}); } | ||
}, | ||
}), | ||
}); | ||
} | ||
if (typeof module === 'object' && module.exports) { | ||
jasmine.getEnv().beforeAll(function () { return addMatchers(); }); | ||
jasmine.getEnv().beforeEach(function () { return initTestScheduler(); }); | ||
jasmine.getEnv().afterEach(function () { | ||
jasmine.getEnv().beforeAll(() => addMatchers()); | ||
jasmine.getEnv().beforeEach(() => initTestScheduler()); | ||
jasmine.getEnv().afterEach(() => { | ||
getTestScheduler().flush(); | ||
@@ -98,0 +96,0 @@ resetTestScheduler(); |
@@ -221,5 +221,5 @@ /** | ||
function deleteErrorNotificationStack(marble) { | ||
var notification = marble.notification; | ||
const { notification } = marble; | ||
if (notification) { | ||
var kind = notification.kind, exception = notification.exception; | ||
const { kind, exception } = notification; | ||
if (kind === 'E' && exception instanceof Error) { | ||
@@ -238,11 +238,11 @@ notification.exception = { | ||
expected = expected.map(deleteErrorNotificationStack); | ||
var passed = isEqual(actual, expected); | ||
const passed = isEqual(actual, expected); | ||
if (passed) { | ||
return; | ||
} | ||
var message_1 = '\nExpected \n'; | ||
actual.forEach(function (x) { return (message_1 += "\t" + stringify(x) + "\n"); }); | ||
message_1 += '\t\nto deep equal \n'; | ||
expected.forEach(function (x) { return (message_1 += "\t" + stringify(x) + "\n"); }); | ||
expect(passed).toEqual(message_1); | ||
let message = '\nExpected \n'; | ||
actual.forEach((x) => (message += `\t${stringify(x)}\n`)); | ||
message += '\t\nto deep equal \n'; | ||
expected.forEach((x) => (message += `\t${stringify(x)}\n`)); | ||
expect(passed).toEqual(message); | ||
} | ||
@@ -249,0 +249,0 @@ else { |
import { TestScheduler } from 'rxjs/testing'; | ||
import { observableMatcher } from './matcher'; | ||
var scheduler; | ||
let scheduler; | ||
export function initTestScheduler() { | ||
@@ -5,0 +5,0 @@ scheduler = new TestScheduler(observableMatcher); |
@@ -1,45 +0,27 @@ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
import { Observable } from 'rxjs'; | ||
import { getTestScheduler } from './scheduler'; | ||
var TestColdObservable = /** @class */ (function (_super) { | ||
__extends(TestColdObservable, _super); | ||
function TestColdObservable(marbles, values, error) { | ||
var _this = _super.call(this) || this; | ||
_this.marbles = marbles; | ||
_this.values = values; | ||
_this.error = error; | ||
_this.source = getTestScheduler().createColdObservable(marbles, values, error); | ||
return _this; | ||
export class TestColdObservable extends Observable { | ||
constructor(marbles, values, error) { | ||
super(); | ||
this.marbles = marbles; | ||
this.values = values; | ||
this.error = error; | ||
this.source = getTestScheduler().createColdObservable(marbles, values, error); | ||
} | ||
TestColdObservable.prototype.getSubscriptions = function () { | ||
getSubscriptions() { | ||
return this.source['subscriptions']; | ||
}; | ||
return TestColdObservable; | ||
}(Observable)); | ||
export { TestColdObservable }; | ||
var TestHotObservable = /** @class */ (function (_super) { | ||
__extends(TestHotObservable, _super); | ||
function TestHotObservable(marbles, values, error) { | ||
var _this = _super.call(this) || this; | ||
_this.marbles = marbles; | ||
_this.values = values; | ||
_this.error = error; | ||
_this.source = getTestScheduler().createHotObservable(marbles, values, error); | ||
return _this; | ||
} | ||
TestHotObservable.prototype.getSubscriptions = function () { | ||
} | ||
export class TestHotObservable extends Observable { | ||
constructor(marbles, values, error) { | ||
super(); | ||
this.marbles = marbles; | ||
this.values = values; | ||
this.error = error; | ||
this.source = getTestScheduler().createHotObservable(marbles, values, error); | ||
} | ||
getSubscriptions() { | ||
return this.source['subscriptions']; | ||
}; | ||
return TestHotObservable; | ||
}(Observable)); | ||
export { TestHotObservable }; | ||
} | ||
} | ||
//# sourceMappingURL=test-observables.js.map |
@@ -14,3 +14,3 @@ import { TestColdObservable, TestHotObservable } from './src/test-observables'; | ||
namespace jest { | ||
interface Matchers<T> { | ||
interface Matchers<R> { | ||
toBeObservable: any; | ||
@@ -17,0 +17,0 @@ toHaveSubscriptions: any; |
18
index.js
@@ -34,3 +34,3 @@ "use strict"; | ||
frame: scheduler.frame - outerFrame, | ||
notification: rxjs_1.Notification.createNext(value) | ||
notification: rxjs_1.Notification.createNext(value), | ||
}); | ||
@@ -40,3 +40,3 @@ }, function (err) { | ||
frame: scheduler.frame - outerFrame, | ||
notification: rxjs_1.Notification.createError(err) | ||
notification: rxjs_1.Notification.createError(err), | ||
}); | ||
@@ -46,3 +46,3 @@ }, function () { | ||
frame: scheduler.frame - outerFrame, | ||
notification: rxjs_1.Notification.createComplete() | ||
notification: rxjs_1.Notification.createComplete(), | ||
}); | ||
@@ -62,3 +62,3 @@ }); | ||
return { pass: true }; | ||
} | ||
}, | ||
}); }, | ||
@@ -79,3 +79,3 @@ toBeObservable: function () { return ({ | ||
frame: scheduler.frame, | ||
notification: rxjs_1.Notification.createNext(value) | ||
notification: rxjs_1.Notification.createNext(value), | ||
}); | ||
@@ -85,3 +85,3 @@ }, function (err) { | ||
frame: scheduler.frame, | ||
notification: rxjs_1.Notification.createError(err) | ||
notification: rxjs_1.Notification.createError(err), | ||
}); | ||
@@ -91,3 +91,3 @@ }, function () { | ||
frame: scheduler.frame, | ||
notification: rxjs_1.Notification.createComplete() | ||
notification: rxjs_1.Notification.createComplete(), | ||
}); | ||
@@ -100,4 +100,4 @@ }); | ||
return { pass: true }; | ||
} | ||
}); } | ||
}, | ||
}); }, | ||
}); | ||
@@ -104,0 +104,0 @@ } |
{ | ||
"name": "jasmine-marbles", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"module": "index.js", | ||
"es2015": "es6/index.js", | ||
"browser": "bundles/jasmine-marbles.umd.js", | ||
"main": "index.js", | ||
"main": "bundles/jasmine-marbles.umd.js", | ||
"license": "MIT", | ||
@@ -9,0 +8,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112077
1186