-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: runtime functionality for easier development testing (#972)
- Loading branch information
Showing
4 changed files
with
85 additions
and
5 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { getPayPalDomain, getDevTouchpoint } from '../../../../../src/utils/sdk'; | ||
|
||
describe('getPayPalDomain', () => { | ||
beforeEach(() => { | ||
// reset test variables | ||
window.__TEST_ENV__ = undefined; | ||
__ENV__ = 'stage'; | ||
__MESSAGES__ = { | ||
__TEST_ENV__: undefined, | ||
__DOMAIN__: { __SANDBOX__: 'https://www.sandbox.com', __STAGE__: 'https://www.stage.com' } | ||
}; | ||
}); | ||
test('returns message test environment if window test environment is not set', () => { | ||
__MESSAGES__.__TEST_ENV__ = 'https://www.test-env.com'; | ||
expect(getPayPalDomain()).toBe('https://www.test-env.com'); | ||
}); | ||
test('returns window test environment if it is set', () => { | ||
__MESSAGES__.__TEST_ENV__ = 'https://www.test-env.com'; | ||
window.__TEST_ENV__ = 'https://www.window-test-env.com'; | ||
expect(getPayPalDomain()).toBe('https://www.window-test-env.com'); | ||
}); | ||
test('returns sandbox domain if no test environment is set and env is sandbox', () => { | ||
__MESSAGES__.__TEST_ENV__ = 'https://www.test-env.com'; | ||
window.__TEST_ENV__ = 'https://www.window-test-env.com'; | ||
__ENV__ = 'sandbox'; | ||
expect(getPayPalDomain()).toBe('https://www.sandbox.com'); | ||
}); | ||
test('returns stage domain if no test environment is set', () => { | ||
expect(getPayPalDomain()).toBe('https://www.stage.com'); | ||
}); | ||
}); | ||
|
||
describe('getDevTouchpoint', () => { | ||
beforeEach(() => { | ||
// reset test variables | ||
window.__DEV_TOUCHPOINT__ = undefined; | ||
__ENV__ = 'stage'; | ||
__MESSAGES__ = { | ||
__DEV_TOUCHPOINT__: undefined | ||
}; | ||
}); | ||
test('returns true if window devTouchpoint is set', () => { | ||
window.__DEV_TOUCHPOINT__ = true; | ||
expect(getDevTouchpoint()).toBe(true); | ||
}); | ||
test('returns undefined if window devTouchpoint is set to false', () => { | ||
window.__DEV_TOUCHPOINT__ = false; | ||
expect(getDevTouchpoint()).toBe(undefined); | ||
}); | ||
test('returns true if window devTouchpoint is not set and message devTouchpoint is true', () => { | ||
__MESSAGES__.__DEV_TOUCHPOINT__ = true; | ||
expect(getDevTouchpoint()).toBe(true); | ||
}); | ||
test('returns true if window devTouchpoint is set and message devTouchpoint is false ', () => { | ||
window.__DEV_TOUCHPOINT__ = true; | ||
__MESSAGES__.__DEV_TOUCHPOINT__ = false; | ||
expect(getDevTouchpoint()).toBe(true); | ||
}); | ||
test('returns undefined if window devTouchpoint is set to false and message devTouchpoint is true ', () => { | ||
window.__DEV_TOUCHPOINT__ = false; | ||
__MESSAGES__.__DEV_TOUCHPOINT__ = true; | ||
expect(getDevTouchpoint()).toBe(undefined); | ||
}); | ||
test('returns undefined if env is not stage', () => { | ||
window.__DEV_TOUCHPOINT__ = true; | ||
__ENV__ = 'sandbox'; | ||
expect(getDevTouchpoint()).toBe(undefined); | ||
}); | ||
}); |