Created
September 8, 2020 07:27
-
-
Save perjo927/3544c5506a19a5c43a25e4fdfb39ae93 to your computer and use it in GitHub Desktop.
Test subscriber
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { makeSubscriber } from "../src/redux/store/subscribe.js"; | |
import assert from "assert"; | |
describe("subscribe.js", () => { | |
describe("makeSubscriber", () => { | |
it("generates a function from subscribers", () => { | |
const subscribers = []; | |
const subscriber = makeSubscriber(subscribers); | |
assert.equal(subscriber.hasOwnProperty("subscribe"), true); | |
}); | |
it("calls the subscriber", () => { | |
const subscribers = []; | |
const spyOnSubscribe = { called: false }; | |
const { subscribe } = makeSubscriber(subscribers); | |
subscribe(() => (spyOnSubscribe.called = true)); | |
subscribers.forEach((subscription) => subscription()); | |
const expected = true; | |
const actual = spyOnSubscribe.called; | |
assert.equal(actual, expected); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment