Something went wrong on our end
Select Git revision
-
Volker Schukai authoredVolker Schukai authored
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);
})
});
});
});