Skip to content
Snippets Groups Projects
Select Git revision
  • ec485f70aad5465cabd336fe4dc025344de1fb7e
  • master default protected
  • 1.31
  • 4.28.0
  • 4.27.0
  • 4.26.0
  • 4.25.5
  • 4.25.4
  • 4.25.3
  • 4.25.2
  • 4.25.1
  • 4.25.0
  • 4.24.3
  • 4.24.2
  • 4.24.1
  • 4.24.0
  • 4.23.6
  • 4.23.5
  • 4.23.4
  • 4.23.3
  • 4.23.2
  • 4.23.1
  • 4.23.0
23 results

release.nix

Blame
  • fetch.mjs 1.39 KiB
    import {expect} from "chai"
    
    
    import {Fetch} from "../../../../../application/source/i18n/providers/fetch.mjs";
    import {Translations} from "../../../../../application/source/i18n/translations.mjs";
    import {getGlobal} from "../../../../../application/source/types/global.mjs";
    
    
    const global = getGlobal();
    let fetchReference;
    
    
    describe('Translation Provider Fetch', function () {
    
    
        afterEach(() => {
            global['fetch'] = fetchReference;
        });
    
        beforeEach(() => {
    
            fetchReference = global['fetch'];
            global['fetch'] = function (url, options) {
                return new Promise((resolve, reject) => {
                    resolve({
                        json: function () {
                            return {
                                a: "test"
                            }
                        }
                    });
                })
    
            };
    
        })
    
        describe('fetch mock data and create translation', function () {
    
            it('fetch', function (done) {
    
                let p = (new Fetch(new URL('http://example.com'))).getTranslations('en');
    
                expect(p).is.instanceof(Promise);
    
                p.then(r => {
    
                    try {
                        expect(r).is.instanceof(Translations);
                        done();
                    } catch (e) {
                        done(e);
                    }
    
    
                }).catch(e => {
                    done(e);
                })
    
            });
    
        });
    
    
    });