Skip to content

Commit 30155cd

Browse files
committed
chore update
1 parent 7fbc782 commit 30155cd

20 files changed

+433
-333
lines changed

packages/angular/.eslintrc.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,20 @@
4747
"import/no-extraneous-dependencies": [
4848
"error",
4949
{
50-
"devDependencies": ["**/*.spec.ts"],
51-
"packageDir": "./" // Needed for angular library support
50+
"devDependencies": [
51+
"**/*.spec.ts"
52+
],
53+
"packageDir": "./"
5254
}
5355
],
5456
"tsdoc/syntax": "warn",
55-
"unicorn/filename-case": "off", // We are naming files with capitals
56-
// I think some of these are silly. `e` is bad, but `err` and `exc` are decent. `user of users` is confusing, `usr of users` is safer.
57+
"unicorn/filename-case": "off",
5758
"unicorn/prevent-abbreviations": "off"
5859
},
5960
"settings": {
6061
"import/resolver": {
6162
"typescript": {
62-
"alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
63+
"alwaysTryTypes": true
6364
}
6465
}
6566
}

packages/angular/angular.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"test": {
2727
"builder": "@angular-devkit/build-angular:karma",
2828
"options": {
29-
"main": "projects/tx-native-angular-sdk/test.ts",
29+
"polyfills": ["zone.js", "zone.js/testing"],
3030
"tsConfig": "projects/tx-native-angular-sdk/tsconfig.spec.json",
3131
"karmaConfig": "projects/tx-native-angular-sdk/karma.conf.js",
3232
"codeCoverage": true
@@ -46,5 +46,12 @@
4646
}
4747
}
4848
},
49-
"defaultProject": "@transifex/angular"
49+
"schematics": {
50+
"@angular-eslint/schematics:application": {
51+
"setParserOptionsProject": true
52+
},
53+
"@angular-eslint/schematics:library": {
54+
"setParserOptionsProject": true
55+
}
56+
}
5057
}

packages/angular/package.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@transifex/angular-projects",
3-
"version": "6.0.1",
3+
"version": "6.0.0",
44
"description": "i18n Angular framework using Transifex Native",
55
"keywords": [
66
"transifex",
@@ -32,34 +32,34 @@
3232
},
3333
"private": true,
3434
"dependencies": {
35-
"@angular/animations": "~14.3.0",
36-
"@angular/common": "~14.3.0",
37-
"@angular/compiler": "~14.3.0",
38-
"@angular/core": "~14.3.0",
39-
"@angular/forms": "~14.3.0",
40-
"@angular/platform-browser": "^14.3.0",
41-
"@angular/platform-browser-dynamic": "^14.3.0",
42-
"@angular/router": "~14.3.0",
43-
"@transifex/native": "^6.0.1",
35+
"@angular/animations": "~16.2.7",
36+
"@angular/common": "~16.2.7",
37+
"@angular/compiler": "~16.2.7",
38+
"@angular/core": "~16.2.7",
39+
"@angular/forms": "~16.2.7",
40+
"@angular/platform-browser": "^16.2.7",
41+
"@angular/platform-browser-dynamic": "^16.2.7",
42+
"@angular/router": "~16.2.7",
43+
"@transifex/native": "^6.0.0",
4444
"rxjs": "~6.6.0",
4545
"tslib": "^2.0.0",
46-
"zone.js": "~0.11.4"
46+
"zone.js": "~0.13.3"
4747
},
4848
"devDependencies": {
49-
"@angular-devkit/architect": "^0.1402.11",
50-
"@angular-devkit/build-angular": "^14.2.11",
51-
"@angular-eslint/builder": "^14.4.0",
52-
"@angular-eslint/eslint-plugin": "^14.4.0",
53-
"@angular-eslint/eslint-plugin-template": "^14.4.0",
54-
"@angular-eslint/schematics": "14.4.0",
55-
"@angular-eslint/template-parser": "^14.4.0",
56-
"@angular/cli": "^14.2.11",
57-
"@angular/compiler-cli": "^14.3.0",
49+
"@angular-devkit/architect": "^0.1602.4",
50+
"@angular-devkit/build-angular": "^16.2.4",
51+
"@angular-eslint/builder": "^16.2.0",
52+
"@angular-eslint/eslint-plugin": "^16.2.0",
53+
"@angular-eslint/eslint-plugin-template": "^16.2.0",
54+
"@angular-eslint/schematics": "16.2.0",
55+
"@angular-eslint/template-parser": "^16.2.0",
56+
"@angular/cli": "^16.2.4",
57+
"@angular/compiler-cli": "^16.2.7",
5858
"@types/jasmine": "~4.0.0",
5959
"@types/node": "^16.18.23",
60-
"@typescript-eslint/eslint-plugin": "^5.36.2",
61-
"@typescript-eslint/parser": "^5.36.2",
62-
"eslint": "^8.23.0",
60+
"@typescript-eslint/eslint-plugin": "^5.59.2",
61+
"@typescript-eslint/parser": "^5.59.2",
62+
"eslint": "^8.39.0",
6363
"eslint-config-airbnb-typescript": "^16.0.0",
6464
"eslint-import-resolver-typescript": "^3.5.5",
6565
"eslint-plugin-import": "^2.25.3",
@@ -76,8 +76,8 @@
7676
"karma-coverage": "~2.2.0",
7777
"karma-jasmine": "~5.1.0",
7878
"karma-jasmine-html-reporter": "^2.1.0",
79-
"ng-packagr": "^14.2.2",
79+
"ng-packagr": "^16.2.3",
8080
"ts-node": "~8.3.0",
81-
"typescript": "~4.6.4"
81+
"typescript": "~4.9.5"
8282
}
8383
}

packages/angular/projects/tx-native-angular-sdk/.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"rules": {
1919
"@angular-eslint/component-selector": [
20-
"off", // We are not following the angular styleguide to match other implementations
20+
"off",
2121
{
2222
"prefix": "tx",
2323
"style": "kebab-case",

packages/angular/projects/tx-native-angular-sdk/tests/T.component.spec.ts renamed to packages/angular/projects/tx-native-angular-sdk/src/tests/T.component.spec.ts

Lines changed: 84 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
import { ReplaySubject } from 'rxjs';
32
import { tx } from '@transifex/native';
3+
import { ReplaySubject } from 'rxjs';
44

5-
import { TComponent } from '../src/lib/T.component';
6-
import { SafeHtmlPipe, TranslationService, TXInstanceComponent } from '../src/public-api';
7-
5+
import { TComponent } from '../lib/T.component';
6+
import {
7+
SafeHtmlPipe,
8+
TranslationService,
9+
TXInstanceComponent,
10+
} from '../public-api';
811

912
describe('TComponent', () => {
1013
let localeChangedSubject: ReplaySubject<string>;
@@ -30,16 +33,19 @@ describe('TComponent', () => {
3033
await TestBed.configureTestingModule({
3134
declarations: [TComponent, SafeHtmlPipe, TXInstanceComponent],
3235
providers: [TXInstanceComponent],
33-
})
34-
.compileComponents();
36+
}).compileComponents();
3537

3638
localeChangedSubject = new ReplaySubject<string>(0);
3739

3840
service = TestBed.inject(TranslationService);
3941
instance = TestBed.inject(TXInstanceComponent);
4042

4143
spyOn(service, 'getCurrentLocale').and.returnValue('en');
42-
localeChangedSpy = spyOnProperty(service, 'localeChanged', 'get').and.returnValue(localeChangedSubject);
44+
localeChangedSpy = spyOnProperty(
45+
service,
46+
'localeChanged',
47+
'get'
48+
).and.returnValue(localeChangedSubject);
4349
spyOn(service, 'setCurrentLocale').and.callFake(async (locale) => {
4450
localeChangedSubject.next(locale);
4551
});
@@ -54,8 +60,11 @@ describe('TComponent', () => {
5460
it('should create the component', async () => {
5561
// setup
5662
spyOn(component, 'translate');
57-
localeChangedSpy = spyOnProperty(component, 'localeChanged', 'get')
58-
.and.returnValue(localeChangedSubject);
63+
localeChangedSpy = spyOnProperty(
64+
component,
65+
'localeChanged',
66+
'get'
67+
).and.returnValue(localeChangedSubject);
5968

6069
// act
6170
component.ngOnInit();
@@ -82,8 +91,11 @@ describe('TComponent', () => {
8291
fixture.detectChanges();
8392

8493
// assert
85-
expect(service.translate).toHaveBeenCalledWith('not-translated',
86-
{ ...translationParams }, '');
94+
expect(service.translate).toHaveBeenCalledWith(
95+
'not-translated',
96+
{ ...translationParams },
97+
''
98+
);
8799
expect(component.translatedStr).toEqual('translated');
88100
});
89101

@@ -98,8 +110,11 @@ describe('TComponent', () => {
98110
fixture.detectChanges();
99111

100112
// assert
101-
expect(service.translate).toHaveBeenCalledWith('not-translated',
102-
{ ...translationParams }, '');
113+
expect(service.translate).toHaveBeenCalledWith(
114+
'not-translated',
115+
{ ...translationParams },
116+
''
117+
);
103118
expect(component.translatedStr).toEqual('translated');
104119
});
105120

@@ -114,8 +129,11 @@ describe('TComponent', () => {
114129
fixture.detectChanges();
115130

116131
// assert
117-
expect(service.translate).toHaveBeenCalledWith('not-translated',
118-
{ ...translationParams, _key: 'key-not-translated' }, '');
132+
expect(service.translate).toHaveBeenCalledWith(
133+
'not-translated',
134+
{ ...translationParams, _key: 'key-not-translated' },
135+
''
136+
);
119137
expect(component.translatedStr).toEqual('translated');
120138
});
121139

@@ -130,8 +148,9 @@ describe('TComponent', () => {
130148

131149
// assert
132150
const compiled = fixture.debugElement.nativeElement;
133-
expect((compiled as HTMLDivElement).innerHTML)
134-
.toContain('&lt;a&gt;translated&lt;/a&gt;');
151+
expect((compiled as HTMLDivElement).innerHTML).toContain(
152+
'&lt;a&gt;translated&lt;/a&gt;'
153+
);
135154
});
136155

137156
it('should translate and sanitize the string', () => {
@@ -146,8 +165,9 @@ describe('TComponent', () => {
146165

147166
// assert
148167
const compiled = fixture.debugElement.nativeElement;
149-
expect((compiled as HTMLDivElement).innerHTML)
150-
.toContain('<span><a>translated</a></span>');
168+
expect((compiled as HTMLDivElement).innerHTML).toContain(
169+
'<span><a>translated</a></span>'
170+
);
151171
});
152172

153173
it('should detect input parameters change and translate', () => {
@@ -158,14 +178,15 @@ describe('TComponent', () => {
158178
// act
159179
service.translate('test', { ...translationParams });
160180
component.str = 'other-value';
161-
component.ngOnChanges()
181+
component.ngOnChanges();
162182
fixture.detectChanges();
163183

164184
// assert
165185
expect(service.translate).toHaveBeenCalled();
166186
const compiled = fixture.debugElement.nativeElement;
167-
expect((compiled as HTMLDivElement).innerHTML)
168-
.toContain('&lt;a&gt;translated&lt;/a&gt;');
187+
expect((compiled as HTMLDivElement).innerHTML).toContain(
188+
'&lt;a&gt;translated&lt;/a&gt;'
189+
);
169190
});
170191

171192
it('should detect localeChange and translate', async () => {
@@ -183,8 +204,11 @@ describe('TComponent', () => {
183204
fixture.detectChanges();
184205

185206
// assert
186-
expect(service.translate).toHaveBeenCalledWith('not-translated',
187-
{ ...translationParams, _key: 'key-not-translated' }, '');
207+
expect(service.translate).toHaveBeenCalledWith(
208+
'not-translated',
209+
{ ...translationParams, _key: 'key-not-translated' },
210+
''
211+
);
188212
expect(component.translatedStr).toEqual('translated-again');
189213
});
190214

@@ -203,11 +227,15 @@ describe('TComponent', () => {
203227
fixture.detectChanges();
204228

205229
// assert
206-
expect(service.translate).toHaveBeenCalledWith('not-translated', {
207-
...translationParams,
208-
_key: 'key-not-translated',
209-
_context: 'late',
210-
}, '');
230+
expect(service.translate).toHaveBeenCalledWith(
231+
'not-translated',
232+
{
233+
...translationParams,
234+
_key: 'key-not-translated',
235+
_context: 'late',
236+
},
237+
''
238+
);
211239
expect(component.translatedStr).toEqual('translated');
212240
});
213241

@@ -223,8 +251,11 @@ describe('TComponent', () => {
223251
fixture.detectChanges();
224252

225253
// assert
226-
expect(service.translate).toHaveBeenCalledWith('not-translated',
227-
{ ...translationParams }, 'instance-alias');
254+
expect(service.translate).toHaveBeenCalledWith(
255+
'not-translated',
256+
{ ...translationParams },
257+
'instance-alias'
258+
);
228259
expect(component.translatedStr).toEqual('translated');
229260
});
230261

@@ -245,24 +276,26 @@ describe('TComponent', () => {
245276
expect(service.translate).toHaveBeenCalled();
246277
});
247278

248-
it('should detect translationsFetched using alternative instance',
249-
async () => {
250-
// setup
251-
instance.token = 'instance-token';
252-
instance.alias = 'instance-alias';
253-
spyOn(service, 'translate').and.returnValue('translated');
254-
255-
// act
256-
component.str = 'not-translated';
257-
component.ngOnInit();
258-
fixture.detectChanges();
259-
260-
// change
261-
await service.fetchTranslations('tag1');
262-
fixture.detectChanges();
263-
264-
// assert
265-
expect(service.translate).toHaveBeenCalledWith('not-translated',
266-
{ ...translationParams }, 'instance-alias');
267-
});
279+
it('should detect translationsFetched using alternative instance', async () => {
280+
// setup
281+
instance.token = 'instance-token';
282+
instance.alias = 'instance-alias';
283+
spyOn(service, 'translate').and.returnValue('translated');
284+
285+
// act
286+
component.str = 'not-translated';
287+
component.ngOnInit();
288+
fixture.detectChanges();
289+
290+
// change
291+
await service.fetchTranslations('tag1');
292+
fixture.detectChanges();
293+
294+
// assert
295+
expect(service.translate).toHaveBeenCalledWith(
296+
'not-translated',
297+
{ ...translationParams },
298+
'instance-alias'
299+
);
300+
});
268301
});

0 commit comments

Comments
 (0)