-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I write a test
const store = createStore(reducers.todos);
const listenerA = expect.createSpy(() => {});
const listenerB = expect.createSpy(() => {});
let unsubscribeA = store.subscribe(listenerA);
store.subscribe(listenerB);
unsubscribeA();
unsubscribeA();//invoke two times
store.dispatch(unknownAction());
expect(listenerA.calls.length).toBe(0);
expect(listenerB.calls.length).toBe(1); // failed
reason:
arr.splice(-1,1) still remove the item of the arr.
//createStore.js
function subscribe(listener) {
listeners.push(listener);
return function unsubscribe() {
var index = listeners.indexOf(listener);
// if index ===1 ,should return
listeners.splice(index, 1);
};
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working