Find Jobs
Hire Freelancers

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?
Project ID: 14967155

About the project

2 proposals
Remote project
Active 7 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
2 freelancers are bidding on average $38 USD for this job
User Avatar
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
$50 USD in 1 day
5.0 (25 reviews)
5.1
5.1

About the client

Flag of UNITED STATES
Mountain View, United States
5.0
83
Payment method verified
Member since Oct 26, 2006

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.