-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Pano Skylakis <[email protected]> Co-authored-by: Zach Couchman <[email protected]> Co-authored-by: Charlie McKenzie <[email protected]>
- Loading branch information
1 parent
4235517
commit e47396c
Showing
27 changed files
with
252 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,41 @@ | ||
/** @jest-environment jsdom */ | ||
import { SDK_VERSION_MARKER } from '../env'; | ||
import { loadUnresolved } from './load'; | ||
import { getWidgetsEsmUrl, loadUnresolvedBundle } from './load'; | ||
|
||
describe('load', () => { | ||
const SDK_VERSION = SDK_VERSION_MARKER; | ||
const scriptId = 'immutable-checkout-widgets-bundle'; | ||
|
||
beforeEach(() => { | ||
jest.spyOn(console, 'warn').mockImplementation(() => {}); | ||
}); | ||
|
||
describe('Config', () => { | ||
describe('load unresolved bundle', () => { | ||
it('should validate the versioning', () => { | ||
loadUnresolved(); | ||
const tag = document.createElement('script'); | ||
loadUnresolvedBundle(tag, scriptId, SDK_VERSION); | ||
expect(document.head.innerHTML).toBe( | ||
'<script id="immutable-checkout-widgets-bundle" ' | ||
+ 'data-version="__SDK_VERSION__" ' | ||
+ `src="https://cdn.jsdelivr.net/npm/@imtbl/sdk@${SDK_VERSION}/dist/browser/checkout/widgets.js"></script>`, | ||
); | ||
}); | ||
}); | ||
|
||
it('should not re-add script', () => { | ||
loadUnresolved(); | ||
loadUnresolved(); | ||
loadUnresolved(); | ||
expect(document.head.innerHTML).toBe( | ||
'<script id="immutable-checkout-widgets-bundle" ' | ||
+ 'data-version="__SDK_VERSION__" ' | ||
+ `src="https://cdn.jsdelivr.net/npm/@imtbl/sdk@${SDK_VERSION}/dist/browser/checkout/widgets.js"></script>`, | ||
describe('get widgets esm url', () => { | ||
it('should validate the versioning', () => { | ||
expect(getWidgetsEsmUrl()).toEqual( | ||
`https://cdn.jsdelivr.net/npm/@imtbl/sdk@${SDK_VERSION}/dist/browser/checkout/widgets-esm.js`, | ||
); | ||
}); | ||
|
||
it('should change version', () => { | ||
loadUnresolved(); | ||
loadUnresolved({ | ||
expect(getWidgetsEsmUrl({ | ||
major: 1, | ||
minor: 2, | ||
}); | ||
expect(document.head.innerHTML).toBe( | ||
'<script id="immutable-checkout-widgets-bundle" ' | ||
+ 'data-version="__SDK_VERSION__" ' | ||
+ `src="https://cdn.jsdelivr.net/npm/@imtbl/sdk@${SDK_VERSION}/dist/browser/checkout/widgets.js"></script>`, | ||
patch: 3, | ||
})).toEqual( | ||
'https://cdn.jsdelivr.net/npm/@imtbl/[email protected]/dist/browser/checkout/widgets-esm.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
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
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
Oops, something went wrong.