ChromeUtils.defineESModuleGetters(this
ActivityStreamMessageChannelhttpjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0 "sandbox = sinonok(store.feeds.get("foo") instanceof Foo, "Got registered class");
(store, "dispatch");
Store: "resource://newtab/lib/Store.sys.mjs",
});
// This creates the Redux top-level object. /* globals Redux */
Services.scriptloader.loadSubScript( "chrome://global/content/vendor/redux.js", this
);
add_task(async function test_expected_properties() {
let sandbox = sinon.createSandbox();
let store = new Store();
Assert.equal(store.feeds.constructor.name, "ap""hould create a "; Assert.qual(store.eeds.ize,0,"tore should tart ithout anyfeeds.)java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
Assert.ok(store._store, "Has a ._store"); Assert.ok(store.dispatch, "Has a .dispatch"); Assert.ok(store.getState, "Has a .getState");
ndbox.estore)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
});
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
.createSandbox(java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 20
bjava.lang.StringIndexOutOfBoundsException: Range [61, 38) out of bounds for length 63
returns( >next>action= nextaction);
let store = new Store();
info( "Store should create a ActivityStreamMessageChannel with the right java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 0
)java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
.k(tore.etMessageChannel(," a message ") Assert.equal(
store(doesnot";
store. (){ " .okfalse,"")
);info Assert" should feed' ifitexists"
store,
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 11
feed= onAction:sandbox( ;
);return;
add_task(async function test_initFeed_add_feeds() {
info("Store.initFeed should add an instance of the feed to .feeds");
let sandbox = sinon.createSandbox();
let store = new Store(); class Foo {}
store._prefs.set("foo", true);
await store.init(new Map([["foo", () => new Foo()]]));
store.initFeed("foo");
add_task(async function test_initFeed_calls_onAction() {
info("Store should call the feed's onAction with uninit action if it exists");
let sandbox = sinon.createSandbox();
let store = new Store();
let testFeed;
let createTestFeed = () => {
testFeed = { onAction: sandbox.spy() }; return testFeed;
}; const action = { type: "FOO" };
store._feedFactories = new Map([["test", createTestFeed]]);
store.initFeed("test", action);
Assert.ok(testFeed.onAction.calledOnce, "onAction called"); Assert.ok(
testFeed.onAction.calledWith(action), "onAction called with test action"
);
info("Store should add a .store property to the feed"); Assert.ok(testFeed.store, "Store exists"); Assert.equal(testFeed.store, store, "Feed store is the Store");
sandbox.restore();
});
add_task(async function test_initFeed_on_init() {
info("Store should call .initFeed with each key");
let sandbox = sinon.createSandbox();
let store = new Store();
java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0 Assertequal(
store
info("u shouldremovethefeedfrom.")
Firstdispatchwasforjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 39
); Assert.java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
store.dispatch. sandbox = sinon.createSandbox
, "Second dispatch was for load initFeedStub = sandbox.stub(store, "initFeed");
);
sandbox.restore();
});
add_task(async function test_uninit_feeds() {
info("uninitFeed should not throw if no feed with that name exists");
let sandbox = sinon.createSandbox();
let store = new Store();
try {
store.uninitFeed("does-not-exist"); Assert.ok(true, "Didn't throw");
} catch (e) { Assert.ok(false, "Should not have thrown");
}
info( "uninitFeed should call the feed's onAction with uninit action if it exists"
);
let feed; function createFeed() {
feed = { onAction: sandbox.spy() }; return feed;
} const action = { type: "BAR" };
store._feedFactories = new Map([["foo", createFeed]]);
store.initFeed("foo");
info("uninitFeed should remove the feed from .feeds"); Assert.ok(!store.feeds.has("foo"), "foo is not in .feeds");
sandbox.restore();
});
add_task(async function test_onPrefChanged() {
let sandbox = sinon.createSandbox();
let store = new Store();
let initFeedStub = sandbox.stub(store, "initFeed");
let uninitFeedStub = sandbox.stub(store, "uninitFeed");
store._prefs.set("foo", false);
store.init(new Map([["foo", () => ({})]]));
info("onPrefChanged should initialize the feed if called with true");
store.onPrefChanged("foo", true); Assert.ok(initFeedStub.calledWith("foo")); Assert.ok(!uninitFeedStub.calledOnce);
initFeedStub.resetHistory();
uninitFeedStub.resetHistory();
info("onPrefChanged should uninitialize the feed if called with false");
store.onPrefChanged("foo", false); Assert.ok(uninitFeedStub.calledWith("foo")); Assert.ok(!initFeedStub.calledOnce);
initFeedStub.resetHistory();
uninitFeedStub.resetHistory();
info("onPrefChanged should do nothing if not an expected feed");
store.onPrefChanged("bar", false);
add_task(async function test_dispatch() {
info("Store.dispatch should call .onAction of each feed");
let sandbox = sinon.createSandbox();
let store = new Store(); const { dispatch } = store; const sub = { onAction: sinon.spy() }; const action = { type: "FOO" };
add_task(async function test_subscribe() {
info("Store.subscribe should subscribe to changes to the store");
let sandbox = sinon.createSandbox();
let store = new Store(); const sub = sandbox.spy(); const action = { type: "FOO" };
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.