@ngx-translate/core#TranslatePipe TypeScript Examples

The following examples show how to use @ngx-translate/core#TranslatePipe. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: translate-testing.module.ts    From mylog14 with GNU General Public License v3.0 6 votes vote down vote up
@NgModule({
  declarations: [
    TranslatePipeMock
  ],
  providers: [
    { provide: TranslateService, useClass: TranslateServiceStub },
    { provide: TranslatePipe, useClass: TranslatePipeMock },
  ],
  imports: [
    TranslateModule.forRoot({
      loader: { provide: TranslateLoader, useClass: FakeLoader },
    })
  ],
  exports: [
    TranslatePipeMock,
    TranslateModule
  ]
})
export class TranslateTestingModule {

}
Example #2
Source File: project-navigation.component.spec.ts    From taiga-front-next with GNU Affero General Public License v3.0 4 votes vote down vote up
describe('ProjectNavigationComponent', () => {
  let spectator: Spectator<ProjectNavigationComponent>;

  const createHost = createHostFactory({
    component: ProjectNavigationComponent,
    schemas: [ NO_ERRORS_SCHEMA ],
    declarations: [
      MockPipe(TranslatePipe),
    ],
    providers: [
      { provide: LegacyService, useClass: LegacyServiceMock },
    ],
    imports: [
      ReactiveComponentModule,
    ],
    mocks: [
      TranslateService,
      Router,
    ],
  });

  it('videconference url', () => {
    const project = {
      ...ProjectMockFactory.build(),
      videoconferences: 'talky',
      videoconferencesExtraData: 'testExtraData',
    };

    spectator = createHost(`<tg-project-navigation [project]="project"></tg-project-navigation>`, {
      hostProps: {
        project,
      },
    });

    expect(spectator.component.videoUrl).toEqual(`https://talky.io/${project.slug}-testextradata`);
  });

  it('jitsi videconference url replace dashes', () => {
    const project = {
      ...ProjectMockFactory.build(),
      videoconferences: 'jitsi',
      videoconferencesExtraData: 'test-extra-data',
      slug: 'project-slug-url',
    };

    spectator = createHost(`<tg-project-navigation [project]="project"></tg-project-navigation>`, {
      hostProps: {
        project,
      },
    });

    expect(spectator.component.videoUrl).toEqual(`https://meet.jit.si/projectslugurltestextradata`);
  });


  it('custom url', () => {
    const custom = 'https://mycustom-url';

    const project = {
      ...ProjectMockFactory.build(),
      videoconferences: 'custom',
      videoconferencesExtraData: custom,
    };

    spectator = createHost(`<tg-project-navigation [project]="project"></tg-project-navigation>`, {
      hostProps: {
        project,
      },
    });

    expect(spectator.component.videoUrl).toEqual(custom);
  });

  describe('menu active', () => {
    const legacyServiceMockFactory = (section = '', breadcrumb: string[] = []) => {
      return {
        legacyState: of({}),
        getInjector() {
          return {
            get:  () => {
              return {
                sectionsBreadcrumb: {
                  toJS: () => breadcrumb,
                },
                section,
              };
            },
          };
        },
      };
    };

    it('backlog', () => {
        const project = {
          ...ProjectMockFactory.build(),
        };

        spectator = createHost(`<tg-project-navigation [project]="project"></tg-project-navigation>`, {
          hostProps: {
            project,
          },
          providers: [
            {
              provide: LegacyService,
              useValue: legacyServiceMockFactory('backlog'),
            },
          ],
        });

        expect(spectator.component.section).toEqual('backlog');
    });

    it('backlog-kanban when only kanban is enabled', () => {
      const project = {
        ...ProjectMockFactory.build(),
        isKanbanActivated: true,
        isBacklogActivated: false,
      };

      spectator = createHost(`<tg-project-navigation [project]="project"></tg-project-navigation>`, {
        hostProps: {
          project,
        },
        providers: [
          {
            provide: LegacyService,
            useValue: legacyServiceMockFactory('backlog-kanban'),
          },
        ],
      });

      expect(spectator.component.section).toEqual('kanban');
    });

    it('backlog-kanban when only backlog is enabled', () => {
      const project = {
        ...ProjectMockFactory.build(),
        isKanbanActivated: false,
        isBacklogActivated: true,
      };

      spectator = createHost(`<tg-project-navigation [project]="project"></tg-project-navigation>`, {
        hostProps: {
          project,
        },
        providers: [
          {
            provide: LegacyService,
            useValue: legacyServiceMockFactory('backlog-kanban'),
          },
        ],
      });

      expect(spectator.component.section).toEqual('backlog');
    });

    it('backlog-kanban when is kanban child', () => {
      const project = {
        ...ProjectMockFactory.build(),
        isKanbanActivated: true,
        isBacklogActivated: true,
      };

      spectator = createHost(`<tg-project-navigation [project]="project"></tg-project-navigation>`, {
        hostProps: {
          project,
        },
        providers: [
          {
            provide: LegacyService,
            useValue: legacyServiceMockFactory('backlog-kanban', ['backlog', 'kanban']),
          },
        ],
      });

      expect(spectator.component.section).toEqual('kanban');
    });

    it('backlog-kanban when is backlog child', () => {
      const project = {
        ...ProjectMockFactory.build(),
        isKanbanActivated: true,
        isBacklogActivated: true,
      };

      spectator = createHost(`<tg-project-navigation [project]="project"></tg-project-navigation>`, {
        hostProps: {
          project,
        },
        providers: [
          {
            provide: LegacyService,
            useValue: legacyServiceMockFactory('backlog-kanban', ['kanban', 'backlog']),
          },
        ],
      });

      expect(spectator.component.section).toEqual('backlog');
    });
  });
});