https://github.com/hetznercloud/ngx-translate-mock
https://github.com/hetznercloud/ngx-translate-mock
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/hetznercloud/ngx-translate-mock
- Owner: hetznercloud
- Created: 2019-03-27T14:29:58.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T02:48:26.000Z (over 2 years ago)
- Last Synced: 2025-04-26T02:52:07.224Z (about 1 year ago)
- Language: TypeScript
- Size: 980 KB
- Stars: 9
- Watchers: 4
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NgxTranslateMock
[](https://badge.fury.io/js/@hetznercloud%2Fngx-translate-mock)
This packages provides a mock module for [ngx-translate](https://github.com/ngx-translate/core).
It includes mocks for the `TranslateService`, the `TranslateDirective` and the `TranslatePipe`.
Not all methods of the service have been mocked yet, feel free to open a pull-request.
## How to use
Import the module in your `TestBed` testing module.
```ts
import { TestBed } from '@angular/core/testing';
import { TranslateMockModule } from '@hetznercloud/ngx-translate-mock';
TestBed.configureTestingModule({
imports: [TranslateMockModule],
});
```
### TranslateMockDirective, TranslateMockPipe
With this module you can also get reliable (snapshot) test results and check whether the translation string was correct or not.
To do this the directive and pipe append `-i18n` to the translation string:
```html
MY.TRANSLATION.STRING-i18n
```
### TranslateServiceMock
The `TranslateServiceMock` acts similar to the real service. For example,
`use()` emits `onLangChange`, or `get` returns the passed in translation string with `-i18n` appended.
## License
MIT license