Skip to content

Commit

Permalink
test: extend oneui util tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlo Bernardini committed Jun 18, 2019
1 parent b15bbea commit bcca439
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/OneUI/OneUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class OneUI {
* @param {number} themeConfig.maxTime - Max time to wait for the theme to be loaded
* @param {Object} themeConfig.ponyfillOptions - Set of options that can be used to configure the ponyfill. Options: https://www.npmjs.com/package/css-vars-ponyfill#options
*/
static init({ themeURL = '', maxTime = DEFAULT_LOADING_TIMEOUT, ponyfillOptions } = {}) {
static init({ themeURL = '', maxTime = DEFAULT_LOADING_TIMEOUT, ponyfillOptions }) {
const loadTheme = Promise.all([
OneUI.applyTheme(themeURL),
OneUI.startCssVarsPonyfill(ponyfillOptions)
Expand Down
7 changes: 7 additions & 0 deletions src/utils/OneUI/__tests__/OneUI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,11 @@ describe('OneUI loader that starts the ponyfill and attach the theme to DOM', ()
expect(ponyfillOptions.onError).toBeCalledTimes(1);
});
});

it('should throw an error when timeout expired', () =>
expect(
OneUI.init({
maxTime: 1
})
).rejects.toThrowErrorMatchingSnapshot());
});
3 changes: 3 additions & 0 deletions src/utils/OneUI/__tests__/__snapshots__/OneUI.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`OneUI loader that starts the ponyfill and attach the theme to DOM should throw an error when timeout expired 1`] = `"Theme \\"\\" not loaded. Loading time expired"`;

0 comments on commit bcca439

Please sign in to comment.