Last active
January 20, 2022 09:57
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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