Last active
February 20, 2023 15:08
-
-
Save rjpkuyper/a4850e16dfddd3461994cda4aacdb883 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 { createUrl, getProducts, Paths } from './get-env-vars' | |
describe("GetEnvVars", () => { | |
const MOCKED_PRODUCTS = [{ id: 1 }]; | |
global.fetch = jest.fn(() => Promise.resolve({ | |
json: () => Promise.resolve(MOCKED_PRODUCTS) | |
})); | |
const OLD_ENV = process.env; | |
beforeEach(() => { | |
process.env = { ...OLD_ENV }; | |
delete process.env.NODE_ENV; | |
}); | |
afterEach(() => { | |
process.env = OLD_ENV; | |
}); | |
test('should create a new url', () => { | |
process.env.BASE_URL = 'https://example.com'; | |
expect(createUrl(Paths.PRODUCTS)).toEqual(`${process.env.BASR_URL}/${Paths.PRODUCTS}`); | |
}); | |
test('should get products', async () => { | |
expect(await getProducts()).toEqual(MOCKED_PRODUCTS) | |
}) | |
}) |
Please check out those
PRODCUTS
->PRODUCTS
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please check out those
PRODCUTS
->PRODUCTS