Last active
February 17, 2023 10:39
-
-
Save rjpkuyper/553d7a9086f29acf59a5577d507a46c9 to your computer and use it in GitHub Desktop.
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 { createHttpGet, createUrl, Paths } from './get-env-vars' | |
describe("GetProducts", () => { | |
const products = [{ id: 1 }]; | |
const url = 'https://example.com' | |
const httpGet = jest.fn().mockResolvedValue({ | |
json: jest.fn().mockResolvedValue(products) | |
}); | |
const loggerService = { | |
error: jest.fn() | |
} | |
test('should create a new url', () => { | |
expect(createUrl(Paths.PRODUCTS, url)).toEqual(`${url}/${Paths.PRODUCTS}`); | |
}); | |
test('should get products', async () => { | |
const getProducts = createHttpGet(loggerService, httpGet) | |
expect(await getProducts(url)).toEqual(products) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment