Last active
February 22, 2021 18:38
-
-
Save fernandodof/781bdb9699421db0abb2db6d92ba5c53 to your computer and use it in GitHub Desktop.
This file contains 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
const MOCK_PRICES = [50, 47, 53, 50, 49, 51, 52]; | |
const MOCK_AVERAGE = 50.29; | |
global.fetch = jest.fn(() => Promise.resolve({ | |
json: () => Promise.resolve(MOCK_PRICES) | |
})); | |
describe('Gold prices', () => { | |
let averagePrice; | |
describe('When the average price is called for 7 days', () => { | |
beforeEach(async () => { | |
averagePrice = await getPricesLastDays(7); | |
}); | |
it('Then the correct average should be returned', () => { | |
expect(averagePrice).toEqual({ average: MOCK_AVERAGE }); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment