-
Notifications
You must be signed in to change notification settings - Fork 188
/
on-push.component.spec.ts
48 lines (42 loc) 路 1.48 KB
/
on-push.component.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { createComponentFactory, Spectator } from '@ngneat/spectator';
import { TranslocoService } from '@jsverse/transloco';
import { getTranslocoModule } from '../transloco-testing.module';
import { OnPushComponent } from './on-push.component';
describe('OnPushComponent', () => {
let spectator: Spectator<OnPushComponent>;
const createComponent = createComponentFactory({
component: OnPushComponent,
imports: [
getTranslocoModule({
translocoConfig: { reRenderOnLangChange: true },
}),
],
});
beforeEach(() => (spectator = createComponent()));
it('should translate', () => {
expect(spectator.query('.structural [data-cy=regular]')).toHaveText(
'Regular: home spanish'
);
expect(spectator.query('.structural [data-cy=current-lang]')).toHaveText(
'Current Lang: es'
);
expect(spectator.query('.pipe [data-cy=p-regular]')).toHaveText(
'Regular: home spanish'
);
expect(spectator.query('.pipe [data-cy=p-regular]')).toHaveText(
'Regular: home spanish'
);
const service = spectator.inject(TranslocoService);
service.setActiveLang('en');
spectator.detectChanges();
expect(spectator.query('.structural [data-cy=regular]')).toHaveText(
'Regular: home english'
);
expect(spectator.query('.structural [data-cy=current-lang]')).toHaveText(
'Current Lang: en'
);
expect(spectator.query('.pipe [data-cy=p-regular]')).toHaveText(
'Regular: home english'
);
});
});