Skip to content

Instantly share code, notes, and snippets.

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