Skip to content

Instantly share code, notes, and snippets.

@rjpkuyper
Last active February 17, 2023 10:39
Show Gist options
  • Save rjpkuyper/553d7a9086f29acf59a5577d507a46c9 to your computer and use it in GitHub Desktop.
Save rjpkuyper/553d7a9086f29acf59a5577d507a46c9 to your computer and use it in GitHub Desktop.
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