@hetznercloud/ngx-translate-mock
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

NgxTranslateMock

npm version

This packages provides a mock module for ngx-translate. 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.

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:

<p>MY.TRANSLATION.STRING-i18n</p>

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

/@hetznercloud/ngx-translate-mock/

    Package Sidebar

    Install

    npm i @hetznercloud/ngx-translate-mock

    Weekly Downloads

    285

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    53.2 kB

    Total Files

    20

    Last publish

    Collaborators

    • hcloud
    • wachri