Skip to content

Instantly share code, notes, and snippets.

@deterralba
Last active January 20, 2022 09:57
Show Gist options
  • Save deterralba/c26b30273c434eb23a68b1241012aeb1 to your computer and use it in GitHub Desktop.
Save deterralba/c26b30273c434eb23a68b1241012aeb1 to your computer and use it in GitHub Desktop.
i18next-http-backend mock for jest testing for i18next - HttpApi or Backend object mock
/*
* File: __mocks__/i18next-http-backend.js
* i18n requires a minimal interface for this mock, we don't really
* to fetch our backend to get the translation so the class does nothing.
* Inspired by https://github.com/dotcore64/i18next-fetch-backend/blob/master/src/index.js
*/
/* eslint-disable */
module.exports = class Backend {
constructor(services, options) {
this.init(services, options);
}
type = 'backend';
static type = 'backend';
init(services, options = {}) {
this.services = services;
this.options = { ...this.options, ...options };
}
getLoadPath(languages, namespaces) {}
read(language, namespace, callback) {}
readMulti(languages, namespaces, callback) {}
create(languages, namespace, key, fallbackValue) {}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment