Skip to content
Snippets Groups Projects
Select Git revision
  • b6fb8055ea0fbff329960e5a5f566a2e60b65905
  • main default protected
  • renovate/lock-file-maintenance
  • demo protected
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
18 results

unit.js

Blame
  • Christoph Reiter's avatar
    Reiter, Christoph authored
    While this will never work with old Edge it makes things easier during testing
    where we can't set an id on the script tag. And we still don't know if supporting
    old Edge is even needed.
    5eaa5aad
    History
    unit.js 1.36 KiB
    import {expect, assert} from 'chai';
    import * as utils from '../utils';
    import * as styles from '../styles';
    import '../vpu-mini-spinner.js';
    import '../vpu-spinner.js';
    import '../jsonld.js';
    
    suite('utils', () => {
        test('base64EncodeUnicode', () => {
            expect(utils.base64EncodeUnicode('')).to.equal('');
            expect(utils.base64EncodeUnicode('foo')).to.equal('Zm9v');
            expect(utils.base64EncodeUnicode('äöü')).to.equal('w6TDtsO8');
            expect(utils.base64EncodeUnicode('😊')).to.equal('8J+Yig==');
        });
    
        test('defineCustomElement', () => {
            class SomeElement extends HTMLElement {
                constructor() {
                    super();
                    this.foo = 42;
                }
            }
            var res = utils.defineCustomElement("test-some-element", SomeElement);
            expect(res).to.equal(true);
    
            var node = document.createElement('test-some-element');
            expect(node.foo).to.equal(42);
        });
    
        test('getAPiUrl', () => {
            assert(utils.getAPiUrl().startsWith("http"));
        });
    
        test('setting', () => {
            assert(utils.setting('apiBaseUrl').startsWith("http"));
        });
    
        test('getAssetURL', () => {
            utils.initAssetBaseURL();
            assert.equal(new URL(utils.getAssetURL("foo/bar")).pathname, "/foo/bar");
        });
    
        test('getThemeCSS', () => {
            styles.getThemeCSS();
        });
    });