Help with Sinon unit tests on ES6 function using React context
$10-30 USD
Cancelled
Posted almost 7 years ago
$10-30 USD
Paid on delivery
I have the following file that I am trying to write unit tests for:
---- [login to view URL] -----
import context from "../context";
function getProvider() {
let provider = (context && [login to view URL]) || null;
if (!provider) {
provider = {
provide: function() {
}
};
}
return provider;
};
export const provider = getProvider();
------------------
The problem is that I am unable to mock the React context, so it always falls into the null case.
---- [login to view URL] -----
import {describe, it, beforeEach, afterEach} from "intern!bdd";
import {expect} from "intern/chai!";
import sinon from "sinon";
import * as provider from "src/js/provider";
describe(" provider with context", () => {
let loggingSpy;
beforeEach(() => {
});
afterEach(() => {
[login to view URL]();
});
it("should log a message", () => {
loggingSpy = [login to view URL](provider, "provide");
[login to view URL]("something");
expect([login to view URL]).[login to view URL](true);
});
});
-----------------
How do I pass in the React context to the provider in the unit test?
i have checked the code
i will make the needed instructions to pass in the React context to the provider in the unit test in a word document and will send t to you
Relevant Skills and Experience
i am a javascript expert with 12 years experience
Proposed Milestones
$50 USD - after delivery of the needed instructions