-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
getConfig
referencing config from incorrect location (#1049)
* Initial Commit * Update CHANGELOG.md * Revert some testing code * Get test coverage back up * Test build directory folder before proceeding.
- Loading branch information
Showing
5 changed files
with
90 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
31 changes: 31 additions & 0 deletions
31
packages/pwa-kit-runtime/src/utils/ssr-config.client.test.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2023, Salesforce, Inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
/* eslint-env jest */ | ||
/* eslint max-nested-callbacks:0 */ | ||
|
||
import {getConfig} from './ssr-config.client' | ||
|
||
let windowSpy | ||
|
||
beforeEach(() => { | ||
windowSpy = jest.spyOn(window, 'window', 'get') | ||
}) | ||
|
||
afterEach(() => { | ||
windowSpy.mockRestore() | ||
}) | ||
|
||
describe('Client getConfig', () => { | ||
test('returns window.__CONFIG__ value', () => { | ||
windowSpy.mockImplementation(() => ({ | ||
__CONFIG__: {} | ||
})) | ||
|
||
expect(getConfig()).toEqual({}) | ||
}) | ||
}) |
This file contains 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
33 changes: 33 additions & 0 deletions
33
packages/pwa-kit-runtime/src/utils/ssr-config.server.test.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2023, Salesforce, Inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
/* eslint-env jest */ | ||
/* eslint max-nested-callbacks:0 */ | ||
|
||
import {getConfig} from './ssr-config.server' | ||
|
||
describe('Server "getConfig"', () => { | ||
const env = process.env | ||
|
||
beforeEach(() => { | ||
jest.resetModules() | ||
process.env = {...env} | ||
}) | ||
|
||
afterEach(() => { | ||
process.env = env | ||
}) | ||
|
||
test('throws when no config files are found running remotely', () => { | ||
expect(getConfig).toThrow() | ||
}) | ||
|
||
test('throws when no config files are found running locally', () => { | ||
process.env.AWS_LAMBDA_FUNCTION_NAME = '' | ||
expect(getConfig).toThrow() | ||
}) | ||
}) |