UNPKG

@bbc/spartacus

Version:
45 lines (38 loc) 1.3 kB
import getClientEnvVars from './clientEnvVars'; describe('webpack client config', () => { it('should return empty object when no dotenvConfig passed', () => { const result = getClientEnvVars(); const expected = {}; expect(result).toEqual(expected); }); it('should return empty object when there are no varaibles prefixed with SPARTACUS_', () => { const dotenvConfigMock = { parsed: { FOO: 'bar', BAR: 'foo', NOT_SPARTACUS_PREFIXED: 'foobar', }, }; const result = getClientEnvVars(dotenvConfigMock); const expected = {}; expect(result).toEqual(expected); }); it('should only return variables starting with the prefix SPARTACUS_', () => { const dotenvConfigMock = { parsed: { SPARTACUS_BASE_URL: 'https://www.bbc.com', SPARTACUS_PUBLIC_DIR: 'build/public', SPARTACUS_ASSETS_MANIFEST_PATH: 'build/assets.json', CI: 'false', NOT_SPARTACUS_PREFIXED: 'foobar', }, }; const result = getClientEnvVars(dotenvConfigMock); const expected = { SPARTACUS_BASE_URL: '"https://www.bbc.com"', SPARTACUS_PUBLIC_DIR: '"build/public"', SPARTACUS_ASSETS_MANIFEST_PATH: '"build/assets.json"', }; expect(result).toEqual(expected); }); });