From 2ec74bbb5a501c09052b235313aa9d272536897e Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 4 Oct 2023 07:58:19 +0200 Subject: [PATCH 01/18] chore update --- packages/angular/.eslintrc.json | 11 +- packages/angular/angular.json | 11 +- packages/angular/package.json | 46 +++--- .../tx-native-angular-sdk/.eslintrc.json | 2 +- .../{ => src}/tests/T.component.spec.ts | 135 +++++++++++------- .../{ => src}/tests/T.decorator.spec.ts | 24 +++- .../src/tests/TXNative.module.spec.ts | 41 ++++++ .../{ => src}/tests/UT.component.spec.ts | 110 ++++++++------ .../src/tests/instance.component.spec.ts | 67 +++++++++ .../tests/language-picker.component.spec.ts | 28 ++-- .../tests/load-translations.directive.spec.ts | 16 +-- .../{ => src}/tests/translate.pipe.spec.ts | 34 +++-- .../tests/translation.service.spec.ts | 54 +++++-- .../src/tests/tsconfig.json | 8 ++ .../projects/tx-native-angular-sdk/test.ts | 30 ++-- .../tests/TXNative.module.spec.ts | 47 ------ .../tests/instance.component.spec.ts | 68 --------- .../tx-native-angular-sdk/tsconfig.lib.json | 1 - .../tx-native-angular-sdk/tsconfig.spec.json | 15 +- packages/angular/tsconfig.json | 14 +- 20 files changed, 431 insertions(+), 331 deletions(-) rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/T.component.spec.ts (72%) rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/T.decorator.spec.ts (78%) create mode 100644 packages/angular/projects/tx-native-angular-sdk/src/tests/TXNative.module.spec.ts rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/UT.component.spec.ts (56%) create mode 100644 packages/angular/projects/tx-native-angular-sdk/src/tests/instance.component.spec.ts rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/language-picker.component.spec.ts (84%) rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/load-translations.directive.spec.ts (85%) rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/translate.pipe.spec.ts (83%) rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/translation.service.spec.ts (87%) create mode 100644 packages/angular/projects/tx-native-angular-sdk/src/tests/tsconfig.json delete mode 100644 packages/angular/projects/tx-native-angular-sdk/tests/TXNative.module.spec.ts delete mode 100644 packages/angular/projects/tx-native-angular-sdk/tests/instance.component.spec.ts diff --git a/packages/angular/.eslintrc.json b/packages/angular/.eslintrc.json index 358a3529..44e51918 100644 --- a/packages/angular/.eslintrc.json +++ b/packages/angular/.eslintrc.json @@ -47,19 +47,20 @@ "import/no-extraneous-dependencies": [ "error", { - "devDependencies": ["**/*.spec.ts"], - "packageDir": "./" // Needed for angular library support + "devDependencies": [ + "**/*.spec.ts" + ], + "packageDir": "./" } ], "tsdoc/syntax": "warn", - "unicorn/filename-case": "off", // We are naming files with capitals - // 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. + "unicorn/filename-case": "off", "unicorn/prevent-abbreviations": "off" }, "settings": { "import/resolver": { "typescript": { - "alwaysTryTypes": true // always try to resolve types under `@types` directory even it doesn't contain any source code, like `@types/unist` + "alwaysTryTypes": true } } } diff --git a/packages/angular/angular.json b/packages/angular/angular.json index 48184fa9..83f47bdb 100644 --- a/packages/angular/angular.json +++ b/packages/angular/angular.json @@ -26,7 +26,7 @@ "test": { "builder": "@angular-devkit/build-angular:karma", "options": { - "main": "projects/tx-native-angular-sdk/test.ts", + "polyfills": ["zone.js", "zone.js/testing"], "tsConfig": "projects/tx-native-angular-sdk/tsconfig.spec.json", "karmaConfig": "projects/tx-native-angular-sdk/karma.conf.js", "codeCoverage": true @@ -46,5 +46,12 @@ } } }, - "defaultProject": "@transifex/angular" + "schematics": { + "@angular-eslint/schematics:application": { + "setParserOptionsProject": true + }, + "@angular-eslint/schematics:library": { + "setParserOptionsProject": true + } + } } diff --git a/packages/angular/package.json b/packages/angular/package.json index d5fdb3ae..f47121f6 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -32,34 +32,34 @@ }, "private": true, "dependencies": { - "@angular/animations": "~14.3.0", - "@angular/common": "~14.3.0", - "@angular/compiler": "~14.3.0", - "@angular/core": "~14.3.0", - "@angular/forms": "~14.3.0", - "@angular/platform-browser": "^14.3.0", - "@angular/platform-browser-dynamic": "^14.3.0", - "@angular/router": "~14.3.0", + "@angular/animations": "~16.2.7", + "@angular/common": "~16.2.7", + "@angular/compiler": "~16.2.7", + "@angular/core": "~16.2.7", + "@angular/forms": "~16.2.7", + "@angular/platform-browser": "^16.2.7", + "@angular/platform-browser-dynamic": "^16.2.7", + "@angular/router": "~16.2.7", "@transifex/native": "^6.0.0", "rxjs": "~6.6.0", "tslib": "^2.0.0", - "zone.js": "~0.11.4" + "zone.js": "~0.13.3" }, "devDependencies": { - "@angular-devkit/architect": "^0.1402.11", - "@angular-devkit/build-angular": "^14.2.11", - "@angular-eslint/builder": "^14.4.0", - "@angular-eslint/eslint-plugin": "^14.4.0", - "@angular-eslint/eslint-plugin-template": "^14.4.0", - "@angular-eslint/schematics": "14.4.0", - "@angular-eslint/template-parser": "^14.4.0", - "@angular/cli": "^14.2.11", - "@angular/compiler-cli": "^14.3.0", + "@angular-devkit/architect": "^0.1602.4", + "@angular-devkit/build-angular": "^16.2.4", + "@angular-eslint/builder": "^16.2.0", + "@angular-eslint/eslint-plugin": "^16.2.0", + "@angular-eslint/eslint-plugin-template": "^16.2.0", + "@angular-eslint/schematics": "16.2.0", + "@angular-eslint/template-parser": "^16.2.0", + "@angular/cli": "^16.2.4", + "@angular/compiler-cli": "^16.2.7", "@types/jasmine": "~4.0.0", "@types/node": "^16.18.23", - "@typescript-eslint/eslint-plugin": "^5.36.2", - "@typescript-eslint/parser": "^5.36.2", - "eslint": "^8.23.0", + "@typescript-eslint/eslint-plugin": "^5.59.2", + "@typescript-eslint/parser": "^5.59.2", + "eslint": "^8.39.0", "eslint-config-airbnb-typescript": "^16.0.0", "eslint-import-resolver-typescript": "^3.5.5", "eslint-plugin-import": "^2.25.3", @@ -76,8 +76,8 @@ "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "^2.1.0", - "ng-packagr": "^14.2.2", + "ng-packagr": "^16.2.3", "ts-node": "~8.3.0", - "typescript": "~4.6.4" + "typescript": "~4.9.5" } } diff --git a/packages/angular/projects/tx-native-angular-sdk/.eslintrc.json b/packages/angular/projects/tx-native-angular-sdk/.eslintrc.json index e442ce2d..411f731b 100644 --- a/packages/angular/projects/tx-native-angular-sdk/.eslintrc.json +++ b/packages/angular/projects/tx-native-angular-sdk/.eslintrc.json @@ -17,7 +17,7 @@ }, "rules": { "@angular-eslint/component-selector": [ - "off", // We are not following the angular styleguide to match other implementations + "off", { "prefix": "tx", "style": "kebab-case", diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/T.component.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/T.component.spec.ts similarity index 72% rename from packages/angular/projects/tx-native-angular-sdk/tests/T.component.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/T.component.spec.ts index b5874d63..0fba8d39 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/T.component.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/T.component.spec.ts @@ -1,10 +1,13 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ReplaySubject } from 'rxjs'; import { tx } from '@transifex/native'; +import { ReplaySubject } from 'rxjs'; -import { TComponent } from '../src/lib/T.component'; -import { SafeHtmlPipe, TranslationService, TXInstanceComponent } from '../src/public-api'; - +import { TComponent } from '../lib/T.component'; +import { + SafeHtmlPipe, + TranslationService, + TXInstanceComponent, +} from '../public-api'; describe('TComponent', () => { let localeChangedSubject: ReplaySubject; @@ -30,8 +33,7 @@ describe('TComponent', () => { await TestBed.configureTestingModule({ declarations: [TComponent, SafeHtmlPipe, TXInstanceComponent], providers: [TXInstanceComponent], - }) - .compileComponents(); + }).compileComponents(); localeChangedSubject = new ReplaySubject(0); @@ -39,7 +41,11 @@ describe('TComponent', () => { instance = TestBed.inject(TXInstanceComponent); spyOn(service, 'getCurrentLocale').and.returnValue('en'); - localeChangedSpy = spyOnProperty(service, 'localeChanged', 'get').and.returnValue(localeChangedSubject); + localeChangedSpy = spyOnProperty( + service, + 'localeChanged', + 'get' + ).and.returnValue(localeChangedSubject); spyOn(service, 'setCurrentLocale').and.callFake(async (locale) => { localeChangedSubject.next(locale); }); @@ -54,8 +60,11 @@ describe('TComponent', () => { it('should create the component', async () => { // setup spyOn(component, 'translate'); - localeChangedSpy = spyOnProperty(component, 'localeChanged', 'get') - .and.returnValue(localeChangedSubject); + localeChangedSpy = spyOnProperty( + component, + 'localeChanged', + 'get' + ).and.returnValue(localeChangedSubject); // act component.ngOnInit(); @@ -82,8 +91,11 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -98,8 +110,11 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -114,8 +129,11 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams, _key: 'key-not-translated' }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams, _key: 'key-not-translated' }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -130,8 +148,9 @@ describe('TComponent', () => { // assert const compiled = fixture.debugElement.nativeElement; - expect((compiled as HTMLDivElement).innerHTML) - .toContain('<a>translated</a>'); + expect((compiled as HTMLDivElement).innerHTML).toContain( + '<a>translated</a>' + ); }); it('should translate and sanitize the string', () => { @@ -146,8 +165,9 @@ describe('TComponent', () => { // assert const compiled = fixture.debugElement.nativeElement; - expect((compiled as HTMLDivElement).innerHTML) - .toContain('translated'); + expect((compiled as HTMLDivElement).innerHTML).toContain( + 'translated' + ); }); it('should detect input parameters change and translate', () => { @@ -158,14 +178,15 @@ describe('TComponent', () => { // act service.translate('test', { ...translationParams }); component.str = 'other-value'; - component.ngOnChanges() + component.ngOnChanges(); fixture.detectChanges(); // assert expect(service.translate).toHaveBeenCalled(); const compiled = fixture.debugElement.nativeElement; - expect((compiled as HTMLDivElement).innerHTML) - .toContain('<a>translated</a>'); + expect((compiled as HTMLDivElement).innerHTML).toContain( + '<a>translated</a>' + ); }); it('should detect localeChange and translate', async () => { @@ -183,8 +204,11 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams, _key: 'key-not-translated' }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams, _key: 'key-not-translated' }, + '' + ); expect(component.translatedStr).toEqual('translated-again'); }); @@ -203,11 +227,15 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', { - ...translationParams, - _key: 'key-not-translated', - _context: 'late', - }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { + ...translationParams, + _key: 'key-not-translated', + _context: 'late', + }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -223,8 +251,11 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams }, 'instance-alias'); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams }, + 'instance-alias' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -245,24 +276,26 @@ describe('TComponent', () => { expect(service.translate).toHaveBeenCalled(); }); - it('should detect translationsFetched using alternative instance', - async () => { - // setup - instance.token = 'instance-token'; - instance.alias = 'instance-alias'; - spyOn(service, 'translate').and.returnValue('translated'); - - // act - component.str = 'not-translated'; - component.ngOnInit(); - fixture.detectChanges(); - - // change - await service.fetchTranslations('tag1'); - fixture.detectChanges(); - - // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams }, 'instance-alias'); - }); + it('should detect translationsFetched using alternative instance', async () => { + // setup + instance.token = 'instance-token'; + instance.alias = 'instance-alias'; + spyOn(service, 'translate').and.returnValue('translated'); + + // act + component.str = 'not-translated'; + component.ngOnInit(); + fixture.detectChanges(); + + // change + await service.fetchTranslations('tag1'); + fixture.detectChanges(); + + // assert + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams }, + 'instance-alias' + ); + }); }); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/T.decorator.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/T.decorator.spec.ts similarity index 78% rename from packages/angular/projects/tx-native-angular-sdk/tests/T.decorator.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/T.decorator.spec.ts index 6e9a3cc7..9756b063 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/T.decorator.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/T.decorator.spec.ts @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { tx } from '@transifex/native'; -import { T } from '../src/lib/T.decorator'; +import { T } from '../lib/T.decorator'; describe('T Decorator', () => { @Component({ @@ -16,7 +16,12 @@ describe('T Decorator', () => { template: '
{{ testProperty }}
', }) class TestWithInstanceComponent { - @T('not-trans-dec', { _key: 'test' }, {alias: 'alias', controlled: true, token: ''} ) testProperty!: string; + @T( + 'not-trans-dec', + { _key: 'test' }, + { alias: 'alias', controlled: true, token: '' } + ) + testProperty!: string; } beforeEach(() => { @@ -33,7 +38,9 @@ describe('T Decorator', () => { fixture.detectChanges(); expect(tx.translate).toHaveBeenCalled(); - expect(tx.translate).toHaveBeenCalledWith('not-trans-dec', { _key: 'test' }); + expect(tx.translate).toHaveBeenCalledWith('not-trans-dec', { + _key: 'test', + }); expect(component.testProperty).toBe('ok-translated-dec'); const compiled: HTMLElement = fixture.debugElement.nativeElement; @@ -41,15 +48,20 @@ describe('T Decorator', () => { }); it('should test the decorator T with an instance', () => { - const fixtureWithInstance = TestBed.createComponent(TestWithInstanceComponent); + const fixtureWithInstance = TestBed.createComponent( + TestWithInstanceComponent + ); const component = fixtureWithInstance.componentInstance; fixtureWithInstance.detectChanges(); expect(tx.translate).toHaveBeenCalled(); - expect(tx.translate).toHaveBeenCalledWith('not-trans-dec', { _key: 'test' }); + expect(tx.translate).toHaveBeenCalledWith('not-trans-dec', { + _key: 'test', + }); expect(component.testProperty).toBe('ok-translated-dec'); - const compiled: HTMLElement = fixtureWithInstance.debugElement.nativeElement; + const compiled: HTMLElement = + fixtureWithInstance.debugElement.nativeElement; expect(compiled.innerHTML).toContain('ok-translated-dec'); }); }); diff --git a/packages/angular/projects/tx-native-angular-sdk/src/tests/TXNative.module.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/TXNative.module.spec.ts new file mode 100644 index 00000000..6367dbd9 --- /dev/null +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/TXNative.module.spec.ts @@ -0,0 +1,41 @@ +import { TestBed } from '@angular/core/testing'; +import { TranslationService, TxNativeModule } from '../public-api'; + +class CustomService { + testMethod(): string { + return 'test'; + } +} + +describe('TxNativeModule', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [TxNativeModule], + }); + }); + + it("should not provide 'CustomService' service", () => { + expect(() => TestBed.inject(CustomService)).toThrowError(/No provider for/); + }); +}); + +describe('TxNativeModule.forRoot()', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [TxNativeModule.forRoot()], + }); + }); + + it('should provide services', () => { + // assert + expect(TestBed.inject(TranslationService)).toBeTruthy(); + }); + + it("should provide a single instance for 'TranslationService'", () => { + const translationService: TranslationService = + TestBed.inject(TranslationService); + + // assert + expect(translationService).toBeDefined(); + }); +}); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/UT.component.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/UT.component.spec.ts similarity index 56% rename from packages/angular/projects/tx-native-angular-sdk/tests/UT.component.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/UT.component.spec.ts index c6389d95..798e32ff 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/UT.component.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/UT.component.spec.ts @@ -1,8 +1,12 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; -import { UTComponent } from '../src/lib/UT.component'; -import { SafeHtmlPipe, TranslationService, TXInstanceComponent } from '../src/public-api'; +import { UTComponent } from '../lib/UT.component'; +import { + SafeHtmlPipe, + TranslationService, + TXInstanceComponent, +} from '../public-api'; describe('UTComponent', () => { let component: UTComponent; @@ -23,8 +27,7 @@ describe('UTComponent', () => { await TestBed.configureTestingModule({ declarations: [UTComponent, SafeHtmlPipe, TXInstanceComponent], providers: [TXInstanceComponent], - }) - .compileComponents(); + }).compileComponents(); service = TestBed.inject(TranslationService); spyOn(service, 'setCurrentLocale'); spyOn(service, 'getCurrentLocale').and.returnValue('en'); @@ -39,8 +42,11 @@ describe('UTComponent', () => { it('should create the component', () => { // setup spyOn(component, 'translate'); - const localeChangedSpy = spyOnProperty(component, 'localeChanged', 'get') - .and.returnValue(of('el')); + const localeChangedSpy = spyOnProperty( + component, + 'localeChanged', + 'get' + ).and.returnValue(of('el')); // act component.ngOnInit(); @@ -65,8 +71,11 @@ describe('UTComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -81,45 +90,54 @@ describe('UTComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams, _key: 'key-not-translated' }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams, _key: 'key-not-translated' }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); - it('should translate and sanitize the string using div as wrapper', - () => { - // setup - spyOn(service, 'translate').and.returnValue('translated'); - - // act - component.str = 'not-translated'; - component.ngOnInit(); - fixture.detectChanges(); - - // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams, _inline: false }, ''); - const compiled = fixture.debugElement.nativeElement; - expect((compiled as HTMLDivElement).innerHTML) - .toContain('
translated
'); - }); - - it('should translate and sanitize the string using span as wrapper', - () => { - // setup - spyOn(service, 'translate').and.returnValue('translated'); - - // act - component.str = 'not-translated'; - component.inline = true; - component.ngOnInit(); - fixture.detectChanges(); - - // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams, _inline: true }, ''); - const compiled = fixture.debugElement.nativeElement; - expect((compiled as HTMLDivElement).innerHTML) - .toContain('translated'); - }); + it('should translate and sanitize the string using div as wrapper', () => { + // setup + spyOn(service, 'translate').and.returnValue('translated'); + + // act + component.str = 'not-translated'; + component.ngOnInit(); + fixture.detectChanges(); + + // assert + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams, _inline: false }, + '' + ); + const compiled = fixture.debugElement.nativeElement; + expect((compiled as HTMLDivElement).innerHTML).toContain( + '
translated
' + ); + }); + + it('should translate and sanitize the string using span as wrapper', () => { + // setup + spyOn(service, 'translate').and.returnValue('translated'); + + // act + component.str = 'not-translated'; + component.inline = true; + component.ngOnInit(); + fixture.detectChanges(); + + // assert + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams, _inline: true }, + '' + ); + const compiled = fixture.debugElement.nativeElement; + expect((compiled as HTMLDivElement).innerHTML).toContain( + 'translated' + ); + }); }); diff --git a/packages/angular/projects/tx-native-angular-sdk/src/tests/instance.component.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/instance.component.spec.ts new file mode 100644 index 00000000..c0acc367 --- /dev/null +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/instance.component.spec.ts @@ -0,0 +1,67 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { tx } from '@transifex/native'; + +import { TranslationService, TXInstanceComponent } from '../public-api'; + +describe('TXInstanceComponent', () => { + let component: TXInstanceComponent; + let fixture: ComponentFixture; + let service: TranslationService; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [TXInstanceComponent], + providers: [TXInstanceComponent], + }).compileComponents(); + + service = TestBed.inject(TranslationService); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(TXInstanceComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should create the component and the instance', async () => { + // setup + component.token = 'token'; + component.alias = 'alias'; + spyOn(service, 'addInstance').and.resolveTo(true); + spyOn(service, 'getInstance').and.returnValue(tx); + + // act + await component.ngOnInit(); + fixture.detectChanges(); + + // assert + expect(component).toBeTruthy(); + expect(service).toBeTruthy(); + expect(service.addInstance).toHaveBeenCalled(); + expect(service.getInstance).toHaveBeenCalled(); + component.instanceIsReady.subscribe((value) => expect(value).toBe(true)); + }); + + it('should create the component and fail to create the instance', async () => { + // setup + component.token = 'token'; + component.alias = 'alias'; + spyOn(service, 'addInstance').and.resolveTo(false); + spyOn(service, 'getInstance'); + + // act + await component.ngOnInit(); + fixture.detectChanges(); + + // assert + expect(component).toBeTruthy(); + expect(service).toBeTruthy(); + expect(service.addInstance).toHaveBeenCalled(); + expect(service.getInstance).toHaveBeenCalled(); + component.instanceIsReady.subscribe((value) => expect(value).toBe(false)); + }); +}); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/language-picker.component.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/language-picker.component.spec.ts similarity index 84% rename from packages/angular/projects/tx-native-angular-sdk/tests/language-picker.component.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/language-picker.component.spec.ts index b81c997f..e9c79b80 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/language-picker.component.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/language-picker.component.spec.ts @@ -1,9 +1,13 @@ -import {ComponentFixture, TestBed} from '@angular/core/testing'; -import {By} from '@angular/platform-browser'; -import {of} from 'rxjs'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { of } from 'rxjs'; -import {LanguagePickerComponent} from '../src/lib/language-picker.component'; -import {ILanguage, TranslationService, TXInstanceComponent} from '../src/public-api'; +import { LanguagePickerComponent } from '../lib/language-picker.component'; +import { + ILanguage, + TranslationService, + TXInstanceComponent, +} from '../public-api'; describe('LanguagePickerComponent', () => { let component: LanguagePickerComponent; @@ -20,8 +24,7 @@ describe('LanguagePickerComponent', () => { await TestBed.configureTestingModule({ declarations: [LanguagePickerComponent, TXInstanceComponent], providers: [TXInstanceComponent], - }) - .compileComponents(); + }).compileComponents(); service = TestBed.inject(TranslationService); instance = TestBed.inject(TXInstanceComponent); }); @@ -59,8 +62,7 @@ describe('LanguagePickerComponent', () => { // assert const compiled = fixture.debugElement.nativeElement; const selectOptions = (compiled as HTMLDivElement).querySelector('select'); - expect((compiled as HTMLDivElement).innerHTML) - .toContain(' { fixture.detectChanges(); // assert - const select: HTMLSelectElement = fixture.debugElement.query(By.css('.tx-language-picker')).nativeElement; + const select: HTMLSelectElement = fixture.debugElement.query( + By.css('.tx-language-picker') + ).nativeElement; const optValue = select.options[1]?.value; if (optValue === undefined) { throw new Error('select.options[1]?.value is undefined'); @@ -86,7 +90,9 @@ describe('LanguagePickerComponent', () => { const optLabel = select.options[select.selectedIndex]?.label; if (optLabel === undefined) { - throw new Error('select.options[select.selectedIndex]?.label is undefined'); + throw new Error( + 'select.options[select.selectedIndex]?.label is undefined' + ); } expect(optLabel).toBe('Ελληνικά'); expect(component.onChange).toHaveBeenCalled(); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/load-translations.directive.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/load-translations.directive.spec.ts similarity index 85% rename from packages/angular/projects/tx-native-angular-sdk/tests/load-translations.directive.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/load-translations.directive.spec.ts index dd1b6c21..9830de08 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/load-translations.directive.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/load-translations.directive.spec.ts @@ -1,16 +1,13 @@ -import {Component, DebugElement } from '@angular/core'; +import { Component, DebugElement } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { ReplaySubject } from 'rxjs'; -import { LoadTranslationsDirective, TranslationService } from '../src/public-api'; - +import { LoadTranslationsDirective, TranslationService } from '../public-api'; describe('LoadTranslationsDirective', () => { @Component({ - template: ` -
- `, + template: `
`, }) class TestComponent {} @@ -31,14 +28,15 @@ describe('LoadTranslationsDirective', () => { service = TestBed.inject(TranslationService); spyOn(service, 'getCurrentLocale').and.returnValue('en'); - spyOnProperty(service, 'localeChanged', 'get').and. - returnValue(localeChangedSubject); + spyOnProperty(service, 'localeChanged', 'get').and.returnValue( + localeChangedSubject + ); spyOn(service, 'setCurrentLocale').and.callFake(async (locale) => { localeChangedSubject.next(locale); }); directives = fixture.debugElement.queryAll( - By.directive(LoadTranslationsDirective), + By.directive(LoadTranslationsDirective) ); fixture.detectChanges(); }); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/translate.pipe.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/translate.pipe.spec.ts similarity index 83% rename from packages/angular/projects/tx-native-angular-sdk/tests/translate.pipe.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/translate.pipe.spec.ts index 0a3518aa..49163365 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/translate.pipe.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/translate.pipe.spec.ts @@ -2,9 +2,9 @@ import { ChangeDetectorRef } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { tx } from '@transifex/native'; import { ReplaySubject } from 'rxjs'; -import { TranslatePipe } from '../src/lib/translate.pipe'; -import { TranslationService } from '../src/lib/translation.service'; -import { TXInstanceComponent } from '../src/public-api'; +import { TranslatePipe } from '../lib/translate.pipe'; +import { TranslationService } from '../lib/translation.service'; +import { TXInstanceComponent } from '../public-api'; describe('TranslatePipe', () => { let localeChangedSubject: ReplaySubject; @@ -26,13 +26,16 @@ describe('TranslatePipe', () => { beforeEach(async () => { TestBed.configureTestingModule({ - declarations: [ TXInstanceComponent ], + declarations: [TXInstanceComponent], providers: [ TranslationService, TXInstanceComponent, { provide: ChangeDetectorRef, - useValue: jasmine.createSpyObj('ChangeDetectorRef', [ 'markForCheck' ]), + useValue: jasmine.createSpyObj( + 'ChangeDetectorRef', + ['markForCheck'] + ), }, ], }); @@ -45,7 +48,9 @@ describe('TranslatePipe', () => { localeChangedSubject = new ReplaySubject(0); spyOn(service, 'getCurrentLocale').and.returnValue('en'); - spyOnProperty(service, 'localeChanged', 'get').and.returnValue(localeChangedSubject); + spyOnProperty(service, 'localeChanged', 'get').and.returnValue( + localeChangedSubject + ); spyOn(service, 'setCurrentLocale').and.callFake(async (locale) => { localeChangedSubject.next(locale); }); @@ -91,13 +96,16 @@ describe('TranslatePipe', () => { spyOn(service, 'translate').and.returnValue('translated'); // act - const translatedStr = translatePipe.transform('not-translated', translationParams); + const translatedStr = translatePipe.transform( + 'not-translated', + translationParams + ); // assert expect(service.translate).toHaveBeenCalledWith( - 'not-translated', - { ...translationParams }, - '', + 'not-translated', + { ...translationParams }, + '' ); expect(translatedStr).toEqual('translated'); }); @@ -113,7 +121,11 @@ describe('TranslatePipe', () => { const translatedStr = translatePipe.transform('not-translated'); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', {}, 'alias'); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + {}, + 'alias' + ); expect(translatedStr).toEqual('translated'); }); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/translation.service.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/translation.service.spec.ts similarity index 87% rename from packages/angular/projects/tx-native-angular-sdk/tests/translation.service.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/translation.service.spec.ts index e25e45a2..3a8e70e9 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/translation.service.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/translation.service.spec.ts @@ -1,8 +1,8 @@ import { TestBed } from '@angular/core/testing'; -import { tx, ILanguage, ITranslationConfig, TxNative } from '@transifex/native'; +import { ILanguage, ITranslationConfig, TxNative, tx } from '@transifex/native'; -import { TranslationService } from '../src/lib/translation.service'; -import { ITranslationServiceConfig } from '../src/public-api'; +import { TranslationService } from '../lib/translation.service'; +import { ITranslationServiceConfig } from '../public-api'; describe('TranslationService', () => { let service: TranslationService; @@ -66,11 +66,15 @@ describe('TranslationService', () => { spyOn(tx, 'translate').and.returnValue('translated'); // act - const result = service.translate('not-translated', { ...translationParams }); + const result = service.translate('not-translated', { + ...translationParams, + }); // assert expect(result).toBe('translated'); - expect(tx.translate).toHaveBeenCalledWith('not-translated', { ...translationParams }); + expect(tx.translate).toHaveBeenCalledWith('not-translated', { + ...translationParams, + }); }); it('should translate with key', () => { @@ -78,11 +82,17 @@ describe('TranslationService', () => { spyOn(tx, 'translate').and.returnValue('translated'); // act - const result = service.translate('not-translated', { ...translationParams, _key: 'key-string' }); + const result = service.translate('not-translated', { + ...translationParams, + _key: 'key-string', + }); // assert expect(result).toBe('translated'); - expect(tx.translate).toHaveBeenCalledWith('not-translated', { ...translationParams, _key: 'key-string' }); + expect(tx.translate).toHaveBeenCalledWith('not-translated', { + ...translationParams, + _key: 'key-string', + }); }); it('should translate and escape', () => { @@ -90,11 +100,17 @@ describe('TranslationService', () => { spyOn(tx, 'translate').and.returnValue('Hola {username}'); // act - const result = service.translate('Hello {username}', { ...translationParams, _escapeVars: true }); + const result = service.translate('Hello {username}', { + ...translationParams, + _escapeVars: true, + }); // assert expect(result).toBe('Hola {username}'); - expect(tx.translate).toHaveBeenCalledWith('Hello {username}', { ...translationParams, _escapeVars: true }); + expect(tx.translate).toHaveBeenCalledWith('Hello {username}', { + ...translationParams, + _escapeVars: true, + }); }); it('should set current locale', async () => { @@ -179,7 +195,9 @@ describe('TranslationService', () => { }; // act/assert - await expectAsync(service.addInstance(instanceConfig)).toBeResolvedTo(false); + await expectAsync(service.addInstance(instanceConfig)).toBeResolvedTo( + false + ); expect(tx.controllerOf).not.toHaveBeenCalled(); }); @@ -194,7 +212,9 @@ describe('TranslationService', () => { }; // act/assert - await expectAsync(service.addInstance(instanceConfig)).toBeResolvedTo(false); + await expectAsync(service.addInstance(instanceConfig)).toBeResolvedTo( + false + ); expect(tx.controllerOf).not.toHaveBeenCalled(); }); @@ -247,7 +267,9 @@ describe('TranslationService', () => { await service.fetchTranslations('tag1'); // assert - expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { filterTags: 'tag1' }); + expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { + filterTags: 'tag1', + }); }); it('should fetch translations on demand without custom instance no fetched tags', async () => { @@ -263,7 +285,9 @@ describe('TranslationService', () => { await service.fetchTranslations('tag1'); // assert - expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { filterTags: 'tag1' }); + expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { + filterTags: 'tag1', + }); }); it('should fetch translations on demand with custom instance', async () => { @@ -280,7 +304,9 @@ describe('TranslationService', () => { // assert expect(service.getInstance).toHaveBeenCalledWith('my-instance'); - expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { filterTags: 'tag1' }); + expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { + filterTags: 'tag1', + }); }); it('should not fetch translations on demand if no instance', async () => { diff --git a/packages/angular/projects/tx-native-angular-sdk/src/tests/tsconfig.json b/packages/angular/projects/tx-native-angular-sdk/src/tests/tsconfig.json new file mode 100644 index 00000000..540c1c6c --- /dev/null +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.spec.json", + "compilerOptions": { + "types": ["jasmine"], + "typeRoots": ["../../../../node_modules/@types"] + }, + "include": ["**/*.spec.ts"] +} diff --git a/packages/angular/projects/tx-native-angular-sdk/test.ts b/packages/angular/projects/tx-native-angular-sdk/test.ts index 695bd56e..4a1d5154 100644 --- a/packages/angular/projects/tx-native-angular-sdk/test.ts +++ b/packages/angular/projects/tx-native-angular-sdk/test.ts @@ -1,27 +1,17 @@ // This file is required by karma.conf.js and loads recursively all the .spec and framework files - -import 'zone.js'; import 'zone.js/testing'; -import { getTestBed } from '@angular/core/testing'; -import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from "@angular/platform-browser-dynamic/testing"; - - -declare const require: { - context(path: string, deep?: boolean, filter?: RegExp): { - keys(): string[]; - (id: string): T; - }; -}; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing'; // First, initialize the Angular testing environment. getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting(), { - teardown: { destroyAfterEach: true } - }, + BrowserDynamicTestingModule, + platformBrowserDynamicTesting(), + { + teardown: { destroyAfterEach: true }, + } ); -// Then we find all the tests. -const context = require.context('./tests/', true, /\.spec\.ts$/); -// And load the modules. -context.keys().map(context); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/TXNative.module.spec.ts b/packages/angular/projects/tx-native-angular-sdk/tests/TXNative.module.spec.ts deleted file mode 100644 index ae1493d4..00000000 --- a/packages/angular/projects/tx-native-angular-sdk/tests/TXNative.module.spec.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { TranslationService, TxNativeModule } from '../src/public-api'; - -class CustomService { - testMethod(): string { - return 'test'; - } -} - -describe('TxNativeModule', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [TxNativeModule], - }); - }); - - it('should not provide \'CustomService\' service', () => { - expect( - () => TestBed.inject(CustomService), - ).toThrowError(/No provider for/); - }); -}); - -describe('TxNativeModule.forRoot()', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - TxNativeModule.forRoot(), - ], - }); - }); - - it('should provide services', () => { - // assert - expect(TestBed.inject(TranslationService)).toBeTruthy(); - }); - - it('should provide a single instance for \'TranslationService\'', - () => { - const translationService: TranslationService = TestBed.inject( - TranslationService, - ); - - // assert - expect(translationService).toBeDefined(); - }); -}); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/instance.component.spec.ts b/packages/angular/projects/tx-native-angular-sdk/tests/instance.component.spec.ts deleted file mode 100644 index 31574e41..00000000 --- a/packages/angular/projects/tx-native-angular-sdk/tests/instance.component.spec.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { tx } from '@transifex/native'; - -import { TranslationService, TXInstanceComponent } from '../src/public-api'; - -describe('TXInstanceComponent', () => { - let component: TXInstanceComponent; - let fixture: ComponentFixture; - let service: TranslationService; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ TXInstanceComponent ], - providers: [ TXInstanceComponent ], - }) - .compileComponents(); - - service = TestBed.inject(TranslationService); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(TXInstanceComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - it('should create the component and the instance', async () => { - // setup - component.token = 'token'; - component.alias = 'alias'; - spyOn(service, 'addInstance').and.resolveTo(true); - spyOn(service, 'getInstance').and.returnValue(tx); - - // act - await component.ngOnInit(); - fixture.detectChanges(); - - // assert - expect(component).toBeTruthy(); - expect(service).toBeTruthy(); - expect(service.addInstance).toHaveBeenCalled(); - expect(service.getInstance).toHaveBeenCalled(); - component.instanceIsReady.subscribe((value) => expect(value).toBe(true)); - }); - - it('should create the component and fail to create the instance', async () => { - // setup - component.token = 'token'; - component.alias = 'alias'; - spyOn(service, 'addInstance').and.resolveTo(false); - spyOn(service, 'getInstance'); - - // act - await component.ngOnInit(); - fixture.detectChanges(); - - // assert - expect(component).toBeTruthy(); - expect(service).toBeTruthy(); - expect(service.addInstance).toHaveBeenCalled(); - expect(service.getInstance).toHaveBeenCalled(); - component.instanceIsReady.subscribe((value) => expect(value).toBe(false)); - }); -}); diff --git a/packages/angular/projects/tx-native-angular-sdk/tsconfig.lib.json b/packages/angular/projects/tx-native-angular-sdk/tsconfig.lib.json index 68c6392d..143048d1 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tsconfig.lib.json +++ b/packages/angular/projects/tx-native-angular-sdk/tsconfig.lib.json @@ -3,7 +3,6 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "../../out-tsc/lib", - "target": "es2020", "declaration": true, "declarationMap": true, "inlineSources": true, diff --git a/packages/angular/projects/tx-native-angular-sdk/tsconfig.spec.json b/packages/angular/projects/tx-native-angular-sdk/tsconfig.spec.json index e2ecda63..7fb03743 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tsconfig.spec.json +++ b/packages/angular/projects/tx-native-angular-sdk/tsconfig.spec.json @@ -3,17 +3,8 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "../../out-tsc/spec", - "types": [ - "jasmine", - "node" - ], - "typeRoots": [ "../node_modules/@types" ], + "types": ["jasmine"], + "typeRoots": ["../../node_modules/@types"] }, - "files": [ - "test.ts" - ], - "include": [ - "**/*.spec.ts", - "**/*.d.ts" - ] + "include": ["**/*.spec.ts", "**/*.d.ts"] } diff --git a/packages/angular/tsconfig.json b/packages/angular/tsconfig.json index 6e892de1..09fc3f6d 100644 --- a/packages/angular/tsconfig.json +++ b/packages/angular/tsconfig.json @@ -19,20 +19,26 @@ "experimentalDecorators": true, "moduleResolution": "node", "importHelpers": true, - "target": "es2015", + "target": "ES2022", "module": "es2020", "lib": [ "es2020", "dom" ], - "types": [ "node", "jasmine" ], - "typeRoots": [ "../node_modules/@types" ], + "types": [ + "node", + "jasmine" + ], + "typeRoots": [ + "../node_modules/@types" + ], "paths": { "tx-native-angular-sdk": [ "dist/tx-native-angular-sdk/tx-native-angular-sdk", "dist/tx-native-angular-sdk" ] - } + }, + "useDefineForClassFields": false }, "angularCompilerOptions": { "enableI18nLegacyMessageIdFormat": false, From 836e603959eba33183a715391bf1856136be076c Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:29:09 +0200 Subject: [PATCH 02/18] update support versions --- packages/angular/projects/tx-native-angular-sdk/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/angular/projects/tx-native-angular-sdk/package.json b/packages/angular/projects/tx-native-angular-sdk/package.json index 6ef17d9b..50cea24a 100644 --- a/packages/angular/projects/tx-native-angular-sdk/package.json +++ b/packages/angular/projects/tx-native-angular-sdk/package.json @@ -17,8 +17,8 @@ "repository": "git://github.com/transifex/transifex-javascript.git", "license": "Apache-2.0", "peerDependencies": { - "@angular/common": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0", - "@angular/core": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0", + "@angular/common": "^14.0.0 || ^15.0.0 || ^16.0.0", + "@angular/core": "^14.0.0 || ^15.0.0 || ^16.0.0", "@transifex/native": "^6.0.0" } } From 6069705786e59077bcfa74b0ac70d1400e781789 Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 4 Oct 2023 07:58:19 +0200 Subject: [PATCH 03/18] chore update From e001ca20a194310ca768f55f1a646fd46b79a50c Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:10:37 +0200 Subject: [PATCH 04/18] github.workflows --- .../.github/workflows/angular-versions.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 packages/angular/.github/workflows/angular-versions.yaml diff --git a/packages/angular/.github/workflows/angular-versions.yaml b/packages/angular/.github/workflows/angular-versions.yaml new file mode 100644 index 00000000..79c782d1 --- /dev/null +++ b/packages/angular/.github/workflows/angular-versions.yaml @@ -0,0 +1,39 @@ +name: Angular update + +on: + pull_request: + branches: [ master ] + +jobs: + update-angular: + name: Update Angular + runs-on: ubuntu-latest + + strategy: + matrix: + - angular-version: + - 14.x.x + - 15.x.x + - 16.x.x + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Angular 14 + if: matrix.angular-version == '14.x.x' + steps: + - name: Run Angular 14 + run: npm run ng update @angular/cli@14 @angular/core@14 + + - name: Angular 15 + if: matrix.angular-version == '15.x.x' + steps: + - name: Run Angular 15 steps + run: npm run ng update @angular/cli@15 @angular/core@15 + + - name: Angular 16 + if: matrix.angular-version == '16.x.x' + steps: + - name: Run Angular 16 steps + run: npm run ng update @angular/cli@16 @angular/core@16 From 7f46f347f5be0ec8cb93d6c2f5faca6332f2ea65 Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 11 Oct 2023 09:08:06 +0200 Subject: [PATCH 05/18] working progress on github matrix --- .../.github/workflows/angular-versions.yaml | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/angular/.github/workflows/angular-versions.yaml b/packages/angular/.github/workflows/angular-versions.yaml index 79c782d1..274abd8f 100644 --- a/packages/angular/.github/workflows/angular-versions.yaml +++ b/packages/angular/.github/workflows/angular-versions.yaml @@ -16,24 +16,40 @@ jobs: - 15.x.x - 16.x.x + - node-version: + - 14.20.x + - 16.14.x + - 18.10.x + steps: - name: Check out code uses: actions/checkout@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: Set up Node.js + - run: nvm use ${{ matrix.node-version }} - name: Angular 14 if: matrix.angular-version == '14.x.x' steps: - name: Run Angular 14 - run: npm run ng update @angular/cli@14 @angular/core@14 + - run: npm run install @angular/cli@14 @angular/core@14 + - run: npm run test + - run: npm run build - name: Angular 15 if: matrix.angular-version == '15.x.x' steps: - name: Run Angular 15 steps - run: npm run ng update @angular/cli@15 @angular/core@15 + - run: npm run ng update @angular/cli@15 @angular/core@15 + - run: npm run test + - run: npm run build - name: Angular 16 if: matrix.angular-version == '16.x.x' steps: - name: Run Angular 16 steps - run: npm run ng update @angular/cli@16 @angular/core@16 + - run: npm run ng update @angular/cli@16 @angular/core@16 + - run: npm run test + - run: npm run build From 8cd294bbaa6338282ec127dbb842012dbdc32732 Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 11 Oct 2023 09:20:54 +0200 Subject: [PATCH 06/18] change on angular-version matrix --- .github/workflows/angular-versions.yaml | 55 +++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/angular-versions.yaml diff --git a/.github/workflows/angular-versions.yaml b/.github/workflows/angular-versions.yaml new file mode 100644 index 00000000..de3314e4 --- /dev/null +++ b/.github/workflows/angular-versions.yaml @@ -0,0 +1,55 @@ +name: Angular update + +on: + pull_request: + branches: [ master ] + +jobs: + update-angular: + name: Update Angular + runs-on: ubuntu-latest + + strategy: + matrix: + - angular-version: + - 14.x.x + - 15.x.x + - 16.x.x + + - node-version: + - 14.20.x + - 16.14.x + - 18.10.x + + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: Set up Node.js + - run: nvm use ${{ matrix.node-version }} + + - name: Angular 14 + if: matrix.angular-version == '14.x.x' + steps: + - name: Run Angular 14 + - run: npm run ng update @angular/cli@14 @angular/core@14 + - run: npm run test + - run: npm run build + + - name: Angular 15 + if: matrix.angular-version == '15.x.x' + steps: + - name: Run Angular 15 steps + - run: npm run ng update @angular/cli@15 @angular/core@15 + - run: npm run test + - run: npm run build + + - name: Angular 16 + if: matrix.angular-version == '16.x.x' + steps: + - name: Run Angular 16 steps + - run: npm run ng update @angular/cli@16 @angular/core@16 + - run: npm run test + - run: npm run build From 4c4d5a5c18fe5abda903e09bc467b11ea1b7e986 Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 11 Oct 2023 09:27:00 +0200 Subject: [PATCH 07/18] matrix change --- .github/workflows/angular-versions.yaml | 64 ++++++++++++------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/angular-versions.yaml b/.github/workflows/angular-versions.yaml index de3314e4..073eaf1f 100644 --- a/.github/workflows/angular-versions.yaml +++ b/.github/workflows/angular-versions.yaml @@ -1,8 +1,9 @@ -name: Angular update +name: Update and Test Angular on: - pull_request: - branches: [ master ] + push: + branches: + - main jobs: update-angular: @@ -11,45 +12,44 @@ jobs: strategy: matrix: - - angular-version: - - 14.x.x - - 15.x.x - - 16.x.x - - - node-version: - - 14.20.x - - 16.14.x - - 18.10.x - - steps: + angular-version: + - '14.x.x' + - '15.x.x' + - '16.x.x' + node-version: + - '14.20.x' + - '16.14.x' + - '18.10.x' + + steps: - name: Check out code uses: actions/checkout@v2 - with: - node-version: ${{ matrix.node-version }} - name: Set up Node.js - - run: nvm use ${{ matrix.node-version }} + run: | + nvm install ${{ matrix.node-version }} + nvm use ${{ matrix.node-version }} - name: Angular 14 if: matrix.angular-version == '14.x.x' - steps: - - name: Run Angular 14 - - run: npm run ng update @angular/cli@14 @angular/core@14 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@14 @angular/core@14 + npm install + npm run test + npm run build - name: Angular 15 if: matrix.angular-version == '15.x.x' - steps: - - name: Run Angular 15 steps - - run: npm run ng update @angular/cli@15 @angular/core@15 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@15 @angular/core@15 + npm install + npm run test + npm run build - name: Angular 16 if: matrix.angular-version == '16.x.x' - steps: - - name: Run Angular 16 steps - - run: npm run ng update @angular/cli@16 @angular/core@16 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@16 @angular/core@16 + npm install + npm run test + npm run build From c8919a7fe9366bb18e8c91b0052a9166ed6d4b3a Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 11 Oct 2023 10:36:06 +0200 Subject: [PATCH 08/18] angular 16 no support for node14 --- .github/workflows/angular-versions.yaml | 55 -------------- .../.github/workflows/angular-versions.yaml | 71 ++++++++++--------- 2 files changed, 39 insertions(+), 87 deletions(-) delete mode 100644 .github/workflows/angular-versions.yaml diff --git a/.github/workflows/angular-versions.yaml b/.github/workflows/angular-versions.yaml deleted file mode 100644 index 073eaf1f..00000000 --- a/.github/workflows/angular-versions.yaml +++ /dev/null @@ -1,55 +0,0 @@ -name: Update and Test Angular - -on: - push: - branches: - - main - -jobs: - update-angular: - name: Update Angular - runs-on: ubuntu-latest - - strategy: - matrix: - angular-version: - - '14.x.x' - - '15.x.x' - - '16.x.x' - node-version: - - '14.20.x' - - '16.14.x' - - '18.10.x' - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Node.js - run: | - nvm install ${{ matrix.node-version }} - nvm use ${{ matrix.node-version }} - - - name: Angular 14 - if: matrix.angular-version == '14.x.x' - run: | - npm install -g @angular/cli@14 @angular/core@14 - npm install - npm run test - npm run build - - - name: Angular 15 - if: matrix.angular-version == '15.x.x' - run: | - npm install -g @angular/cli@15 @angular/core@15 - npm install - npm run test - npm run build - - - name: Angular 16 - if: matrix.angular-version == '16.x.x' - run: | - npm install -g @angular/cli@16 @angular/core@16 - npm install - npm run test - npm run build diff --git a/packages/angular/.github/workflows/angular-versions.yaml b/packages/angular/.github/workflows/angular-versions.yaml index 274abd8f..d31be870 100644 --- a/packages/angular/.github/workflows/angular-versions.yaml +++ b/packages/angular/.github/workflows/angular-versions.yaml @@ -1,8 +1,9 @@ -name: Angular update +name: Update and Test Angular on: - pull_request: - branches: [ master ] + push: + branches: + - main jobs: update-angular: @@ -11,45 +12,51 @@ jobs: strategy: matrix: - - angular-version: - - 14.x.x - - 15.x.x - - 16.x.x - - - node-version: - - 14.20.x - - 16.14.x - - 18.10.x - - steps: + angular-version: + - '14.x.x' + - '15.x.x' + - '16.x.x' + node-version: + - '14.20.x' + - '16.14.x' + - '18.10.x' + + steps: - name: Check out code uses: actions/checkout@v2 - with: - node-version: ${{ matrix.node-version }} - name: Set up Node.js - - run: nvm use ${{ matrix.node-version }} + run: | + nvm install ${{ matrix.node-version }} + nvm use ${{ matrix.node-version }} + + + - name: Setup angular node version + if: matrix.angular-version == '16.x.x' + run: | + nvm install 16.13.0 + nvm use 16.13.0 - name: Angular 14 if: matrix.angular-version == '14.x.x' - steps: - - name: Run Angular 14 - - run: npm run install @angular/cli@14 @angular/core@14 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@14 @angular/core@14 + npm install + npm run test + npm run build - name: Angular 15 if: matrix.angular-version == '15.x.x' - steps: - - name: Run Angular 15 steps - - run: npm run ng update @angular/cli@15 @angular/core@15 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@15 @angular/core@15 + npm install + npm run test + npm run build - name: Angular 16 if: matrix.angular-version == '16.x.x' - steps: - - name: Run Angular 16 steps - - run: npm run ng update @angular/cli@16 @angular/core@16 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@16 @angular/core@16 + npm install + npm run test + npm run build From 30155cd035c00df71fda817e279df7f6cffea60c Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 4 Oct 2023 07:58:19 +0200 Subject: [PATCH 09/18] chore update --- packages/angular/.eslintrc.json | 11 +- packages/angular/angular.json | 11 +- packages/angular/package.json | 50 +++---- .../tx-native-angular-sdk/.eslintrc.json | 2 +- .../{ => src}/tests/T.component.spec.ts | 135 +++++++++++------- .../{ => src}/tests/T.decorator.spec.ts | 24 +++- .../src/tests/TXNative.module.spec.ts | 41 ++++++ .../{ => src}/tests/UT.component.spec.ts | 110 ++++++++------ .../src/tests/instance.component.spec.ts | 67 +++++++++ .../tests/language-picker.component.spec.ts | 28 ++-- .../tests/load-translations.directive.spec.ts | 16 +-- .../{ => src}/tests/translate.pipe.spec.ts | 34 +++-- .../tests/translation.service.spec.ts | 54 +++++-- .../src/tests/tsconfig.json | 8 ++ .../projects/tx-native-angular-sdk/test.ts | 30 ++-- .../tests/TXNative.module.spec.ts | 47 ------ .../tests/instance.component.spec.ts | 68 --------- .../tx-native-angular-sdk/tsconfig.lib.json | 1 - .../tx-native-angular-sdk/tsconfig.spec.json | 15 +- packages/angular/tsconfig.json | 14 +- 20 files changed, 433 insertions(+), 333 deletions(-) rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/T.component.spec.ts (72%) rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/T.decorator.spec.ts (78%) create mode 100644 packages/angular/projects/tx-native-angular-sdk/src/tests/TXNative.module.spec.ts rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/UT.component.spec.ts (56%) create mode 100644 packages/angular/projects/tx-native-angular-sdk/src/tests/instance.component.spec.ts rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/language-picker.component.spec.ts (84%) rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/load-translations.directive.spec.ts (85%) rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/translate.pipe.spec.ts (83%) rename packages/angular/projects/tx-native-angular-sdk/{ => src}/tests/translation.service.spec.ts (87%) create mode 100644 packages/angular/projects/tx-native-angular-sdk/src/tests/tsconfig.json delete mode 100644 packages/angular/projects/tx-native-angular-sdk/tests/TXNative.module.spec.ts delete mode 100644 packages/angular/projects/tx-native-angular-sdk/tests/instance.component.spec.ts diff --git a/packages/angular/.eslintrc.json b/packages/angular/.eslintrc.json index 358a3529..44e51918 100644 --- a/packages/angular/.eslintrc.json +++ b/packages/angular/.eslintrc.json @@ -47,19 +47,20 @@ "import/no-extraneous-dependencies": [ "error", { - "devDependencies": ["**/*.spec.ts"], - "packageDir": "./" // Needed for angular library support + "devDependencies": [ + "**/*.spec.ts" + ], + "packageDir": "./" } ], "tsdoc/syntax": "warn", - "unicorn/filename-case": "off", // We are naming files with capitals - // 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. + "unicorn/filename-case": "off", "unicorn/prevent-abbreviations": "off" }, "settings": { "import/resolver": { "typescript": { - "alwaysTryTypes": true // always try to resolve types under `@types` directory even it doesn't contain any source code, like `@types/unist` + "alwaysTryTypes": true } } } diff --git a/packages/angular/angular.json b/packages/angular/angular.json index 48184fa9..83f47bdb 100644 --- a/packages/angular/angular.json +++ b/packages/angular/angular.json @@ -26,7 +26,7 @@ "test": { "builder": "@angular-devkit/build-angular:karma", "options": { - "main": "projects/tx-native-angular-sdk/test.ts", + "polyfills": ["zone.js", "zone.js/testing"], "tsConfig": "projects/tx-native-angular-sdk/tsconfig.spec.json", "karmaConfig": "projects/tx-native-angular-sdk/karma.conf.js", "codeCoverage": true @@ -46,5 +46,12 @@ } } }, - "defaultProject": "@transifex/angular" + "schematics": { + "@angular-eslint/schematics:application": { + "setParserOptionsProject": true + }, + "@angular-eslint/schematics:library": { + "setParserOptionsProject": true + } + } } diff --git a/packages/angular/package.json b/packages/angular/package.json index d55e784a..f47121f6 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -1,6 +1,6 @@ { "name": "@transifex/angular-projects", - "version": "6.0.1", + "version": "6.0.0", "description": "i18n Angular framework using Transifex Native", "keywords": [ "transifex", @@ -32,34 +32,34 @@ }, "private": true, "dependencies": { - "@angular/animations": "~14.3.0", - "@angular/common": "~14.3.0", - "@angular/compiler": "~14.3.0", - "@angular/core": "~14.3.0", - "@angular/forms": "~14.3.0", - "@angular/platform-browser": "^14.3.0", - "@angular/platform-browser-dynamic": "^14.3.0", - "@angular/router": "~14.3.0", - "@transifex/native": "^6.0.1", + "@angular/animations": "~16.2.7", + "@angular/common": "~16.2.7", + "@angular/compiler": "~16.2.7", + "@angular/core": "~16.2.7", + "@angular/forms": "~16.2.7", + "@angular/platform-browser": "^16.2.7", + "@angular/platform-browser-dynamic": "^16.2.7", + "@angular/router": "~16.2.7", + "@transifex/native": "^6.0.0", "rxjs": "~6.6.0", "tslib": "^2.0.0", - "zone.js": "~0.11.4" + "zone.js": "~0.13.3" }, "devDependencies": { - "@angular-devkit/architect": "^0.1402.11", - "@angular-devkit/build-angular": "^14.2.11", - "@angular-eslint/builder": "^14.4.0", - "@angular-eslint/eslint-plugin": "^14.4.0", - "@angular-eslint/eslint-plugin-template": "^14.4.0", - "@angular-eslint/schematics": "14.4.0", - "@angular-eslint/template-parser": "^14.4.0", - "@angular/cli": "^14.2.11", - "@angular/compiler-cli": "^14.3.0", + "@angular-devkit/architect": "^0.1602.4", + "@angular-devkit/build-angular": "^16.2.4", + "@angular-eslint/builder": "^16.2.0", + "@angular-eslint/eslint-plugin": "^16.2.0", + "@angular-eslint/eslint-plugin-template": "^16.2.0", + "@angular-eslint/schematics": "16.2.0", + "@angular-eslint/template-parser": "^16.2.0", + "@angular/cli": "^16.2.4", + "@angular/compiler-cli": "^16.2.7", "@types/jasmine": "~4.0.0", "@types/node": "^16.18.23", - "@typescript-eslint/eslint-plugin": "^5.36.2", - "@typescript-eslint/parser": "^5.36.2", - "eslint": "^8.23.0", + "@typescript-eslint/eslint-plugin": "^5.59.2", + "@typescript-eslint/parser": "^5.59.2", + "eslint": "^8.39.0", "eslint-config-airbnb-typescript": "^16.0.0", "eslint-import-resolver-typescript": "^3.5.5", "eslint-plugin-import": "^2.25.3", @@ -76,8 +76,8 @@ "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "^2.1.0", - "ng-packagr": "^14.2.2", + "ng-packagr": "^16.2.3", "ts-node": "~8.3.0", - "typescript": "~4.6.4" + "typescript": "~4.9.5" } } diff --git a/packages/angular/projects/tx-native-angular-sdk/.eslintrc.json b/packages/angular/projects/tx-native-angular-sdk/.eslintrc.json index e442ce2d..411f731b 100644 --- a/packages/angular/projects/tx-native-angular-sdk/.eslintrc.json +++ b/packages/angular/projects/tx-native-angular-sdk/.eslintrc.json @@ -17,7 +17,7 @@ }, "rules": { "@angular-eslint/component-selector": [ - "off", // We are not following the angular styleguide to match other implementations + "off", { "prefix": "tx", "style": "kebab-case", diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/T.component.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/T.component.spec.ts similarity index 72% rename from packages/angular/projects/tx-native-angular-sdk/tests/T.component.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/T.component.spec.ts index b5874d63..0fba8d39 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/T.component.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/T.component.spec.ts @@ -1,10 +1,13 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ReplaySubject } from 'rxjs'; import { tx } from '@transifex/native'; +import { ReplaySubject } from 'rxjs'; -import { TComponent } from '../src/lib/T.component'; -import { SafeHtmlPipe, TranslationService, TXInstanceComponent } from '../src/public-api'; - +import { TComponent } from '../lib/T.component'; +import { + SafeHtmlPipe, + TranslationService, + TXInstanceComponent, +} from '../public-api'; describe('TComponent', () => { let localeChangedSubject: ReplaySubject; @@ -30,8 +33,7 @@ describe('TComponent', () => { await TestBed.configureTestingModule({ declarations: [TComponent, SafeHtmlPipe, TXInstanceComponent], providers: [TXInstanceComponent], - }) - .compileComponents(); + }).compileComponents(); localeChangedSubject = new ReplaySubject(0); @@ -39,7 +41,11 @@ describe('TComponent', () => { instance = TestBed.inject(TXInstanceComponent); spyOn(service, 'getCurrentLocale').and.returnValue('en'); - localeChangedSpy = spyOnProperty(service, 'localeChanged', 'get').and.returnValue(localeChangedSubject); + localeChangedSpy = spyOnProperty( + service, + 'localeChanged', + 'get' + ).and.returnValue(localeChangedSubject); spyOn(service, 'setCurrentLocale').and.callFake(async (locale) => { localeChangedSubject.next(locale); }); @@ -54,8 +60,11 @@ describe('TComponent', () => { it('should create the component', async () => { // setup spyOn(component, 'translate'); - localeChangedSpy = spyOnProperty(component, 'localeChanged', 'get') - .and.returnValue(localeChangedSubject); + localeChangedSpy = spyOnProperty( + component, + 'localeChanged', + 'get' + ).and.returnValue(localeChangedSubject); // act component.ngOnInit(); @@ -82,8 +91,11 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -98,8 +110,11 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -114,8 +129,11 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams, _key: 'key-not-translated' }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams, _key: 'key-not-translated' }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -130,8 +148,9 @@ describe('TComponent', () => { // assert const compiled = fixture.debugElement.nativeElement; - expect((compiled as HTMLDivElement).innerHTML) - .toContain('<a>translated</a>'); + expect((compiled as HTMLDivElement).innerHTML).toContain( + '<a>translated</a>' + ); }); it('should translate and sanitize the string', () => { @@ -146,8 +165,9 @@ describe('TComponent', () => { // assert const compiled = fixture.debugElement.nativeElement; - expect((compiled as HTMLDivElement).innerHTML) - .toContain('translated'); + expect((compiled as HTMLDivElement).innerHTML).toContain( + 'translated' + ); }); it('should detect input parameters change and translate', () => { @@ -158,14 +178,15 @@ describe('TComponent', () => { // act service.translate('test', { ...translationParams }); component.str = 'other-value'; - component.ngOnChanges() + component.ngOnChanges(); fixture.detectChanges(); // assert expect(service.translate).toHaveBeenCalled(); const compiled = fixture.debugElement.nativeElement; - expect((compiled as HTMLDivElement).innerHTML) - .toContain('<a>translated</a>'); + expect((compiled as HTMLDivElement).innerHTML).toContain( + '<a>translated</a>' + ); }); it('should detect localeChange and translate', async () => { @@ -183,8 +204,11 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams, _key: 'key-not-translated' }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams, _key: 'key-not-translated' }, + '' + ); expect(component.translatedStr).toEqual('translated-again'); }); @@ -203,11 +227,15 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', { - ...translationParams, - _key: 'key-not-translated', - _context: 'late', - }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { + ...translationParams, + _key: 'key-not-translated', + _context: 'late', + }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -223,8 +251,11 @@ describe('TComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams }, 'instance-alias'); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams }, + 'instance-alias' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -245,24 +276,26 @@ describe('TComponent', () => { expect(service.translate).toHaveBeenCalled(); }); - it('should detect translationsFetched using alternative instance', - async () => { - // setup - instance.token = 'instance-token'; - instance.alias = 'instance-alias'; - spyOn(service, 'translate').and.returnValue('translated'); - - // act - component.str = 'not-translated'; - component.ngOnInit(); - fixture.detectChanges(); - - // change - await service.fetchTranslations('tag1'); - fixture.detectChanges(); - - // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams }, 'instance-alias'); - }); + it('should detect translationsFetched using alternative instance', async () => { + // setup + instance.token = 'instance-token'; + instance.alias = 'instance-alias'; + spyOn(service, 'translate').and.returnValue('translated'); + + // act + component.str = 'not-translated'; + component.ngOnInit(); + fixture.detectChanges(); + + // change + await service.fetchTranslations('tag1'); + fixture.detectChanges(); + + // assert + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams }, + 'instance-alias' + ); + }); }); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/T.decorator.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/T.decorator.spec.ts similarity index 78% rename from packages/angular/projects/tx-native-angular-sdk/tests/T.decorator.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/T.decorator.spec.ts index 6e9a3cc7..9756b063 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/T.decorator.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/T.decorator.spec.ts @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { tx } from '@transifex/native'; -import { T } from '../src/lib/T.decorator'; +import { T } from '../lib/T.decorator'; describe('T Decorator', () => { @Component({ @@ -16,7 +16,12 @@ describe('T Decorator', () => { template: '
{{ testProperty }}
', }) class TestWithInstanceComponent { - @T('not-trans-dec', { _key: 'test' }, {alias: 'alias', controlled: true, token: ''} ) testProperty!: string; + @T( + 'not-trans-dec', + { _key: 'test' }, + { alias: 'alias', controlled: true, token: '' } + ) + testProperty!: string; } beforeEach(() => { @@ -33,7 +38,9 @@ describe('T Decorator', () => { fixture.detectChanges(); expect(tx.translate).toHaveBeenCalled(); - expect(tx.translate).toHaveBeenCalledWith('not-trans-dec', { _key: 'test' }); + expect(tx.translate).toHaveBeenCalledWith('not-trans-dec', { + _key: 'test', + }); expect(component.testProperty).toBe('ok-translated-dec'); const compiled: HTMLElement = fixture.debugElement.nativeElement; @@ -41,15 +48,20 @@ describe('T Decorator', () => { }); it('should test the decorator T with an instance', () => { - const fixtureWithInstance = TestBed.createComponent(TestWithInstanceComponent); + const fixtureWithInstance = TestBed.createComponent( + TestWithInstanceComponent + ); const component = fixtureWithInstance.componentInstance; fixtureWithInstance.detectChanges(); expect(tx.translate).toHaveBeenCalled(); - expect(tx.translate).toHaveBeenCalledWith('not-trans-dec', { _key: 'test' }); + expect(tx.translate).toHaveBeenCalledWith('not-trans-dec', { + _key: 'test', + }); expect(component.testProperty).toBe('ok-translated-dec'); - const compiled: HTMLElement = fixtureWithInstance.debugElement.nativeElement; + const compiled: HTMLElement = + fixtureWithInstance.debugElement.nativeElement; expect(compiled.innerHTML).toContain('ok-translated-dec'); }); }); diff --git a/packages/angular/projects/tx-native-angular-sdk/src/tests/TXNative.module.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/TXNative.module.spec.ts new file mode 100644 index 00000000..6367dbd9 --- /dev/null +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/TXNative.module.spec.ts @@ -0,0 +1,41 @@ +import { TestBed } from '@angular/core/testing'; +import { TranslationService, TxNativeModule } from '../public-api'; + +class CustomService { + testMethod(): string { + return 'test'; + } +} + +describe('TxNativeModule', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [TxNativeModule], + }); + }); + + it("should not provide 'CustomService' service", () => { + expect(() => TestBed.inject(CustomService)).toThrowError(/No provider for/); + }); +}); + +describe('TxNativeModule.forRoot()', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [TxNativeModule.forRoot()], + }); + }); + + it('should provide services', () => { + // assert + expect(TestBed.inject(TranslationService)).toBeTruthy(); + }); + + it("should provide a single instance for 'TranslationService'", () => { + const translationService: TranslationService = + TestBed.inject(TranslationService); + + // assert + expect(translationService).toBeDefined(); + }); +}); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/UT.component.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/UT.component.spec.ts similarity index 56% rename from packages/angular/projects/tx-native-angular-sdk/tests/UT.component.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/UT.component.spec.ts index c6389d95..798e32ff 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/UT.component.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/UT.component.spec.ts @@ -1,8 +1,12 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; -import { UTComponent } from '../src/lib/UT.component'; -import { SafeHtmlPipe, TranslationService, TXInstanceComponent } from '../src/public-api'; +import { UTComponent } from '../lib/UT.component'; +import { + SafeHtmlPipe, + TranslationService, + TXInstanceComponent, +} from '../public-api'; describe('UTComponent', () => { let component: UTComponent; @@ -23,8 +27,7 @@ describe('UTComponent', () => { await TestBed.configureTestingModule({ declarations: [UTComponent, SafeHtmlPipe, TXInstanceComponent], providers: [TXInstanceComponent], - }) - .compileComponents(); + }).compileComponents(); service = TestBed.inject(TranslationService); spyOn(service, 'setCurrentLocale'); spyOn(service, 'getCurrentLocale').and.returnValue('en'); @@ -39,8 +42,11 @@ describe('UTComponent', () => { it('should create the component', () => { // setup spyOn(component, 'translate'); - const localeChangedSpy = spyOnProperty(component, 'localeChanged', 'get') - .and.returnValue(of('el')); + const localeChangedSpy = spyOnProperty( + component, + 'localeChanged', + 'get' + ).and.returnValue(of('el')); // act component.ngOnInit(); @@ -65,8 +71,11 @@ describe('UTComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); @@ -81,45 +90,54 @@ describe('UTComponent', () => { fixture.detectChanges(); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams, _key: 'key-not-translated' }, ''); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams, _key: 'key-not-translated' }, + '' + ); expect(component.translatedStr).toEqual('translated'); }); - it('should translate and sanitize the string using div as wrapper', - () => { - // setup - spyOn(service, 'translate').and.returnValue('translated'); - - // act - component.str = 'not-translated'; - component.ngOnInit(); - fixture.detectChanges(); - - // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams, _inline: false }, ''); - const compiled = fixture.debugElement.nativeElement; - expect((compiled as HTMLDivElement).innerHTML) - .toContain(''); - }); - - it('should translate and sanitize the string using span as wrapper', - () => { - // setup - spyOn(service, 'translate').and.returnValue('translated'); - - // act - component.str = 'not-translated'; - component.inline = true; - component.ngOnInit(); - fixture.detectChanges(); - - // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', - { ...translationParams, _inline: true }, ''); - const compiled = fixture.debugElement.nativeElement; - expect((compiled as HTMLDivElement).innerHTML) - .toContain('translated'); - }); + it('should translate and sanitize the string using div as wrapper', () => { + // setup + spyOn(service, 'translate').and.returnValue('translated'); + + // act + component.str = 'not-translated'; + component.ngOnInit(); + fixture.detectChanges(); + + // assert + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams, _inline: false }, + '' + ); + const compiled = fixture.debugElement.nativeElement; + expect((compiled as HTMLDivElement).innerHTML).toContain( + '' + ); + }); + + it('should translate and sanitize the string using span as wrapper', () => { + // setup + spyOn(service, 'translate').and.returnValue('translated'); + + // act + component.str = 'not-translated'; + component.inline = true; + component.ngOnInit(); + fixture.detectChanges(); + + // assert + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + { ...translationParams, _inline: true }, + '' + ); + const compiled = fixture.debugElement.nativeElement; + expect((compiled as HTMLDivElement).innerHTML).toContain( + 'translated' + ); + }); }); diff --git a/packages/angular/projects/tx-native-angular-sdk/src/tests/instance.component.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/instance.component.spec.ts new file mode 100644 index 00000000..c0acc367 --- /dev/null +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/instance.component.spec.ts @@ -0,0 +1,67 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { tx } from '@transifex/native'; + +import { TranslationService, TXInstanceComponent } from '../public-api'; + +describe('TXInstanceComponent', () => { + let component: TXInstanceComponent; + let fixture: ComponentFixture; + let service: TranslationService; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [TXInstanceComponent], + providers: [TXInstanceComponent], + }).compileComponents(); + + service = TestBed.inject(TranslationService); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(TXInstanceComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should create the component and the instance', async () => { + // setup + component.token = 'token'; + component.alias = 'alias'; + spyOn(service, 'addInstance').and.resolveTo(true); + spyOn(service, 'getInstance').and.returnValue(tx); + + // act + await component.ngOnInit(); + fixture.detectChanges(); + + // assert + expect(component).toBeTruthy(); + expect(service).toBeTruthy(); + expect(service.addInstance).toHaveBeenCalled(); + expect(service.getInstance).toHaveBeenCalled(); + component.instanceIsReady.subscribe((value) => expect(value).toBe(true)); + }); + + it('should create the component and fail to create the instance', async () => { + // setup + component.token = 'token'; + component.alias = 'alias'; + spyOn(service, 'addInstance').and.resolveTo(false); + spyOn(service, 'getInstance'); + + // act + await component.ngOnInit(); + fixture.detectChanges(); + + // assert + expect(component).toBeTruthy(); + expect(service).toBeTruthy(); + expect(service.addInstance).toHaveBeenCalled(); + expect(service.getInstance).toHaveBeenCalled(); + component.instanceIsReady.subscribe((value) => expect(value).toBe(false)); + }); +}); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/language-picker.component.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/language-picker.component.spec.ts similarity index 84% rename from packages/angular/projects/tx-native-angular-sdk/tests/language-picker.component.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/language-picker.component.spec.ts index b81c997f..e9c79b80 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/language-picker.component.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/language-picker.component.spec.ts @@ -1,9 +1,13 @@ -import {ComponentFixture, TestBed} from '@angular/core/testing'; -import {By} from '@angular/platform-browser'; -import {of} from 'rxjs'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { of } from 'rxjs'; -import {LanguagePickerComponent} from '../src/lib/language-picker.component'; -import {ILanguage, TranslationService, TXInstanceComponent} from '../src/public-api'; +import { LanguagePickerComponent } from '../lib/language-picker.component'; +import { + ILanguage, + TranslationService, + TXInstanceComponent, +} from '../public-api'; describe('LanguagePickerComponent', () => { let component: LanguagePickerComponent; @@ -20,8 +24,7 @@ describe('LanguagePickerComponent', () => { await TestBed.configureTestingModule({ declarations: [LanguagePickerComponent, TXInstanceComponent], providers: [TXInstanceComponent], - }) - .compileComponents(); + }).compileComponents(); service = TestBed.inject(TranslationService); instance = TestBed.inject(TXInstanceComponent); }); @@ -59,8 +62,7 @@ describe('LanguagePickerComponent', () => { // assert const compiled = fixture.debugElement.nativeElement; const selectOptions = (compiled as HTMLDivElement).querySelector('select'); - expect((compiled as HTMLDivElement).innerHTML) - .toContain(' { fixture.detectChanges(); // assert - const select: HTMLSelectElement = fixture.debugElement.query(By.css('.tx-language-picker')).nativeElement; + const select: HTMLSelectElement = fixture.debugElement.query( + By.css('.tx-language-picker') + ).nativeElement; const optValue = select.options[1]?.value; if (optValue === undefined) { throw new Error('select.options[1]?.value is undefined'); @@ -86,7 +90,9 @@ describe('LanguagePickerComponent', () => { const optLabel = select.options[select.selectedIndex]?.label; if (optLabel === undefined) { - throw new Error('select.options[select.selectedIndex]?.label is undefined'); + throw new Error( + 'select.options[select.selectedIndex]?.label is undefined' + ); } expect(optLabel).toBe('Ελληνικά'); expect(component.onChange).toHaveBeenCalled(); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/load-translations.directive.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/load-translations.directive.spec.ts similarity index 85% rename from packages/angular/projects/tx-native-angular-sdk/tests/load-translations.directive.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/load-translations.directive.spec.ts index dd1b6c21..9830de08 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/load-translations.directive.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/load-translations.directive.spec.ts @@ -1,16 +1,13 @@ -import {Component, DebugElement } from '@angular/core'; +import { Component, DebugElement } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { ReplaySubject } from 'rxjs'; -import { LoadTranslationsDirective, TranslationService } from '../src/public-api'; - +import { LoadTranslationsDirective, TranslationService } from '../public-api'; describe('LoadTranslationsDirective', () => { @Component({ - template: ` -
- `, + template: `
`, }) class TestComponent {} @@ -31,14 +28,15 @@ describe('LoadTranslationsDirective', () => { service = TestBed.inject(TranslationService); spyOn(service, 'getCurrentLocale').and.returnValue('en'); - spyOnProperty(service, 'localeChanged', 'get').and. - returnValue(localeChangedSubject); + spyOnProperty(service, 'localeChanged', 'get').and.returnValue( + localeChangedSubject + ); spyOn(service, 'setCurrentLocale').and.callFake(async (locale) => { localeChangedSubject.next(locale); }); directives = fixture.debugElement.queryAll( - By.directive(LoadTranslationsDirective), + By.directive(LoadTranslationsDirective) ); fixture.detectChanges(); }); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/translate.pipe.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/translate.pipe.spec.ts similarity index 83% rename from packages/angular/projects/tx-native-angular-sdk/tests/translate.pipe.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/translate.pipe.spec.ts index 0a3518aa..49163365 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/translate.pipe.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/translate.pipe.spec.ts @@ -2,9 +2,9 @@ import { ChangeDetectorRef } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { tx } from '@transifex/native'; import { ReplaySubject } from 'rxjs'; -import { TranslatePipe } from '../src/lib/translate.pipe'; -import { TranslationService } from '../src/lib/translation.service'; -import { TXInstanceComponent } from '../src/public-api'; +import { TranslatePipe } from '../lib/translate.pipe'; +import { TranslationService } from '../lib/translation.service'; +import { TXInstanceComponent } from '../public-api'; describe('TranslatePipe', () => { let localeChangedSubject: ReplaySubject; @@ -26,13 +26,16 @@ describe('TranslatePipe', () => { beforeEach(async () => { TestBed.configureTestingModule({ - declarations: [ TXInstanceComponent ], + declarations: [TXInstanceComponent], providers: [ TranslationService, TXInstanceComponent, { provide: ChangeDetectorRef, - useValue: jasmine.createSpyObj('ChangeDetectorRef', [ 'markForCheck' ]), + useValue: jasmine.createSpyObj( + 'ChangeDetectorRef', + ['markForCheck'] + ), }, ], }); @@ -45,7 +48,9 @@ describe('TranslatePipe', () => { localeChangedSubject = new ReplaySubject(0); spyOn(service, 'getCurrentLocale').and.returnValue('en'); - spyOnProperty(service, 'localeChanged', 'get').and.returnValue(localeChangedSubject); + spyOnProperty(service, 'localeChanged', 'get').and.returnValue( + localeChangedSubject + ); spyOn(service, 'setCurrentLocale').and.callFake(async (locale) => { localeChangedSubject.next(locale); }); @@ -91,13 +96,16 @@ describe('TranslatePipe', () => { spyOn(service, 'translate').and.returnValue('translated'); // act - const translatedStr = translatePipe.transform('not-translated', translationParams); + const translatedStr = translatePipe.transform( + 'not-translated', + translationParams + ); // assert expect(service.translate).toHaveBeenCalledWith( - 'not-translated', - { ...translationParams }, - '', + 'not-translated', + { ...translationParams }, + '' ); expect(translatedStr).toEqual('translated'); }); @@ -113,7 +121,11 @@ describe('TranslatePipe', () => { const translatedStr = translatePipe.transform('not-translated'); // assert - expect(service.translate).toHaveBeenCalledWith('not-translated', {}, 'alias'); + expect(service.translate).toHaveBeenCalledWith( + 'not-translated', + {}, + 'alias' + ); expect(translatedStr).toEqual('translated'); }); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/translation.service.spec.ts b/packages/angular/projects/tx-native-angular-sdk/src/tests/translation.service.spec.ts similarity index 87% rename from packages/angular/projects/tx-native-angular-sdk/tests/translation.service.spec.ts rename to packages/angular/projects/tx-native-angular-sdk/src/tests/translation.service.spec.ts index e25e45a2..3a8e70e9 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tests/translation.service.spec.ts +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/translation.service.spec.ts @@ -1,8 +1,8 @@ import { TestBed } from '@angular/core/testing'; -import { tx, ILanguage, ITranslationConfig, TxNative } from '@transifex/native'; +import { ILanguage, ITranslationConfig, TxNative, tx } from '@transifex/native'; -import { TranslationService } from '../src/lib/translation.service'; -import { ITranslationServiceConfig } from '../src/public-api'; +import { TranslationService } from '../lib/translation.service'; +import { ITranslationServiceConfig } from '../public-api'; describe('TranslationService', () => { let service: TranslationService; @@ -66,11 +66,15 @@ describe('TranslationService', () => { spyOn(tx, 'translate').and.returnValue('translated'); // act - const result = service.translate('not-translated', { ...translationParams }); + const result = service.translate('not-translated', { + ...translationParams, + }); // assert expect(result).toBe('translated'); - expect(tx.translate).toHaveBeenCalledWith('not-translated', { ...translationParams }); + expect(tx.translate).toHaveBeenCalledWith('not-translated', { + ...translationParams, + }); }); it('should translate with key', () => { @@ -78,11 +82,17 @@ describe('TranslationService', () => { spyOn(tx, 'translate').and.returnValue('translated'); // act - const result = service.translate('not-translated', { ...translationParams, _key: 'key-string' }); + const result = service.translate('not-translated', { + ...translationParams, + _key: 'key-string', + }); // assert expect(result).toBe('translated'); - expect(tx.translate).toHaveBeenCalledWith('not-translated', { ...translationParams, _key: 'key-string' }); + expect(tx.translate).toHaveBeenCalledWith('not-translated', { + ...translationParams, + _key: 'key-string', + }); }); it('should translate and escape', () => { @@ -90,11 +100,17 @@ describe('TranslationService', () => { spyOn(tx, 'translate').and.returnValue('Hola {username}'); // act - const result = service.translate('Hello {username}', { ...translationParams, _escapeVars: true }); + const result = service.translate('Hello {username}', { + ...translationParams, + _escapeVars: true, + }); // assert expect(result).toBe('Hola {username}'); - expect(tx.translate).toHaveBeenCalledWith('Hello {username}', { ...translationParams, _escapeVars: true }); + expect(tx.translate).toHaveBeenCalledWith('Hello {username}', { + ...translationParams, + _escapeVars: true, + }); }); it('should set current locale', async () => { @@ -179,7 +195,9 @@ describe('TranslationService', () => { }; // act/assert - await expectAsync(service.addInstance(instanceConfig)).toBeResolvedTo(false); + await expectAsync(service.addInstance(instanceConfig)).toBeResolvedTo( + false + ); expect(tx.controllerOf).not.toHaveBeenCalled(); }); @@ -194,7 +212,9 @@ describe('TranslationService', () => { }; // act/assert - await expectAsync(service.addInstance(instanceConfig)).toBeResolvedTo(false); + await expectAsync(service.addInstance(instanceConfig)).toBeResolvedTo( + false + ); expect(tx.controllerOf).not.toHaveBeenCalled(); }); @@ -247,7 +267,9 @@ describe('TranslationService', () => { await service.fetchTranslations('tag1'); // assert - expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { filterTags: 'tag1' }); + expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { + filterTags: 'tag1', + }); }); it('should fetch translations on demand without custom instance no fetched tags', async () => { @@ -263,7 +285,9 @@ describe('TranslationService', () => { await service.fetchTranslations('tag1'); // assert - expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { filterTags: 'tag1' }); + expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { + filterTags: 'tag1', + }); }); it('should fetch translations on demand with custom instance', async () => { @@ -280,7 +304,9 @@ describe('TranslationService', () => { // assert expect(service.getInstance).toHaveBeenCalledWith('my-instance'); - expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { filterTags: 'tag1' }); + expect(tx.fetchTranslations).toHaveBeenCalledWith('en', { + filterTags: 'tag1', + }); }); it('should not fetch translations on demand if no instance', async () => { diff --git a/packages/angular/projects/tx-native-angular-sdk/src/tests/tsconfig.json b/packages/angular/projects/tx-native-angular-sdk/src/tests/tsconfig.json new file mode 100644 index 00000000..540c1c6c --- /dev/null +++ b/packages/angular/projects/tx-native-angular-sdk/src/tests/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.spec.json", + "compilerOptions": { + "types": ["jasmine"], + "typeRoots": ["../../../../node_modules/@types"] + }, + "include": ["**/*.spec.ts"] +} diff --git a/packages/angular/projects/tx-native-angular-sdk/test.ts b/packages/angular/projects/tx-native-angular-sdk/test.ts index 695bd56e..4a1d5154 100644 --- a/packages/angular/projects/tx-native-angular-sdk/test.ts +++ b/packages/angular/projects/tx-native-angular-sdk/test.ts @@ -1,27 +1,17 @@ // This file is required by karma.conf.js and loads recursively all the .spec and framework files - -import 'zone.js'; import 'zone.js/testing'; -import { getTestBed } from '@angular/core/testing'; -import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from "@angular/platform-browser-dynamic/testing"; - - -declare const require: { - context(path: string, deep?: boolean, filter?: RegExp): { - keys(): string[]; - (id: string): T; - }; -}; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing'; // First, initialize the Angular testing environment. getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting(), { - teardown: { destroyAfterEach: true } - }, + BrowserDynamicTestingModule, + platformBrowserDynamicTesting(), + { + teardown: { destroyAfterEach: true }, + } ); -// Then we find all the tests. -const context = require.context('./tests/', true, /\.spec\.ts$/); -// And load the modules. -context.keys().map(context); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/TXNative.module.spec.ts b/packages/angular/projects/tx-native-angular-sdk/tests/TXNative.module.spec.ts deleted file mode 100644 index ae1493d4..00000000 --- a/packages/angular/projects/tx-native-angular-sdk/tests/TXNative.module.spec.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { TranslationService, TxNativeModule } from '../src/public-api'; - -class CustomService { - testMethod(): string { - return 'test'; - } -} - -describe('TxNativeModule', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [TxNativeModule], - }); - }); - - it('should not provide \'CustomService\' service', () => { - expect( - () => TestBed.inject(CustomService), - ).toThrowError(/No provider for/); - }); -}); - -describe('TxNativeModule.forRoot()', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - TxNativeModule.forRoot(), - ], - }); - }); - - it('should provide services', () => { - // assert - expect(TestBed.inject(TranslationService)).toBeTruthy(); - }); - - it('should provide a single instance for \'TranslationService\'', - () => { - const translationService: TranslationService = TestBed.inject( - TranslationService, - ); - - // assert - expect(translationService).toBeDefined(); - }); -}); diff --git a/packages/angular/projects/tx-native-angular-sdk/tests/instance.component.spec.ts b/packages/angular/projects/tx-native-angular-sdk/tests/instance.component.spec.ts deleted file mode 100644 index 31574e41..00000000 --- a/packages/angular/projects/tx-native-angular-sdk/tests/instance.component.spec.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { tx } from '@transifex/native'; - -import { TranslationService, TXInstanceComponent } from '../src/public-api'; - -describe('TXInstanceComponent', () => { - let component: TXInstanceComponent; - let fixture: ComponentFixture; - let service: TranslationService; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ TXInstanceComponent ], - providers: [ TXInstanceComponent ], - }) - .compileComponents(); - - service = TestBed.inject(TranslationService); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(TXInstanceComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - it('should create the component and the instance', async () => { - // setup - component.token = 'token'; - component.alias = 'alias'; - spyOn(service, 'addInstance').and.resolveTo(true); - spyOn(service, 'getInstance').and.returnValue(tx); - - // act - await component.ngOnInit(); - fixture.detectChanges(); - - // assert - expect(component).toBeTruthy(); - expect(service).toBeTruthy(); - expect(service.addInstance).toHaveBeenCalled(); - expect(service.getInstance).toHaveBeenCalled(); - component.instanceIsReady.subscribe((value) => expect(value).toBe(true)); - }); - - it('should create the component and fail to create the instance', async () => { - // setup - component.token = 'token'; - component.alias = 'alias'; - spyOn(service, 'addInstance').and.resolveTo(false); - spyOn(service, 'getInstance'); - - // act - await component.ngOnInit(); - fixture.detectChanges(); - - // assert - expect(component).toBeTruthy(); - expect(service).toBeTruthy(); - expect(service.addInstance).toHaveBeenCalled(); - expect(service.getInstance).toHaveBeenCalled(); - component.instanceIsReady.subscribe((value) => expect(value).toBe(false)); - }); -}); diff --git a/packages/angular/projects/tx-native-angular-sdk/tsconfig.lib.json b/packages/angular/projects/tx-native-angular-sdk/tsconfig.lib.json index 68c6392d..143048d1 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tsconfig.lib.json +++ b/packages/angular/projects/tx-native-angular-sdk/tsconfig.lib.json @@ -3,7 +3,6 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "../../out-tsc/lib", - "target": "es2020", "declaration": true, "declarationMap": true, "inlineSources": true, diff --git a/packages/angular/projects/tx-native-angular-sdk/tsconfig.spec.json b/packages/angular/projects/tx-native-angular-sdk/tsconfig.spec.json index e2ecda63..7fb03743 100644 --- a/packages/angular/projects/tx-native-angular-sdk/tsconfig.spec.json +++ b/packages/angular/projects/tx-native-angular-sdk/tsconfig.spec.json @@ -3,17 +3,8 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "../../out-tsc/spec", - "types": [ - "jasmine", - "node" - ], - "typeRoots": [ "../node_modules/@types" ], + "types": ["jasmine"], + "typeRoots": ["../../node_modules/@types"] }, - "files": [ - "test.ts" - ], - "include": [ - "**/*.spec.ts", - "**/*.d.ts" - ] + "include": ["**/*.spec.ts", "**/*.d.ts"] } diff --git a/packages/angular/tsconfig.json b/packages/angular/tsconfig.json index 6e892de1..09fc3f6d 100644 --- a/packages/angular/tsconfig.json +++ b/packages/angular/tsconfig.json @@ -19,20 +19,26 @@ "experimentalDecorators": true, "moduleResolution": "node", "importHelpers": true, - "target": "es2015", + "target": "ES2022", "module": "es2020", "lib": [ "es2020", "dom" ], - "types": [ "node", "jasmine" ], - "typeRoots": [ "../node_modules/@types" ], + "types": [ + "node", + "jasmine" + ], + "typeRoots": [ + "../node_modules/@types" + ], "paths": { "tx-native-angular-sdk": [ "dist/tx-native-angular-sdk/tx-native-angular-sdk", "dist/tx-native-angular-sdk" ] - } + }, + "useDefineForClassFields": false }, "angularCompilerOptions": { "enableI18nLegacyMessageIdFormat": false, From 1f7a4082fe7e611a989e4dd62560e36c5c29c23b Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:29:09 +0200 Subject: [PATCH 10/18] update support versions --- packages/angular/projects/tx-native-angular-sdk/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/angular/projects/tx-native-angular-sdk/package.json b/packages/angular/projects/tx-native-angular-sdk/package.json index 6ef17d9b..50cea24a 100644 --- a/packages/angular/projects/tx-native-angular-sdk/package.json +++ b/packages/angular/projects/tx-native-angular-sdk/package.json @@ -17,8 +17,8 @@ "repository": "git://github.com/transifex/transifex-javascript.git", "license": "Apache-2.0", "peerDependencies": { - "@angular/common": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0", - "@angular/core": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0", + "@angular/common": "^14.0.0 || ^15.0.0 || ^16.0.0", + "@angular/core": "^14.0.0 || ^15.0.0 || ^16.0.0", "@transifex/native": "^6.0.0" } } From d323b92fffd66e181391a3cca7ddb34e07c1a032 Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 4 Oct 2023 14:10:37 +0200 Subject: [PATCH 11/18] github.workflows --- .../.github/workflows/angular-versions.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 packages/angular/.github/workflows/angular-versions.yaml diff --git a/packages/angular/.github/workflows/angular-versions.yaml b/packages/angular/.github/workflows/angular-versions.yaml new file mode 100644 index 00000000..79c782d1 --- /dev/null +++ b/packages/angular/.github/workflows/angular-versions.yaml @@ -0,0 +1,39 @@ +name: Angular update + +on: + pull_request: + branches: [ master ] + +jobs: + update-angular: + name: Update Angular + runs-on: ubuntu-latest + + strategy: + matrix: + - angular-version: + - 14.x.x + - 15.x.x + - 16.x.x + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Angular 14 + if: matrix.angular-version == '14.x.x' + steps: + - name: Run Angular 14 + run: npm run ng update @angular/cli@14 @angular/core@14 + + - name: Angular 15 + if: matrix.angular-version == '15.x.x' + steps: + - name: Run Angular 15 steps + run: npm run ng update @angular/cli@15 @angular/core@15 + + - name: Angular 16 + if: matrix.angular-version == '16.x.x' + steps: + - name: Run Angular 16 steps + run: npm run ng update @angular/cli@16 @angular/core@16 From e2a240c7fc39825513e594182d5bbdc604786072 Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 4 Oct 2023 07:58:19 +0200 Subject: [PATCH 12/18] chore update From 326eb4b45448c2d496298265154dba440f891ab9 Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 11 Oct 2023 09:08:06 +0200 Subject: [PATCH 13/18] working progress on github matrix --- .../.github/workflows/angular-versions.yaml | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/angular/.github/workflows/angular-versions.yaml b/packages/angular/.github/workflows/angular-versions.yaml index 79c782d1..274abd8f 100644 --- a/packages/angular/.github/workflows/angular-versions.yaml +++ b/packages/angular/.github/workflows/angular-versions.yaml @@ -16,24 +16,40 @@ jobs: - 15.x.x - 16.x.x + - node-version: + - 14.20.x + - 16.14.x + - 18.10.x + steps: - name: Check out code uses: actions/checkout@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: Set up Node.js + - run: nvm use ${{ matrix.node-version }} - name: Angular 14 if: matrix.angular-version == '14.x.x' steps: - name: Run Angular 14 - run: npm run ng update @angular/cli@14 @angular/core@14 + - run: npm run install @angular/cli@14 @angular/core@14 + - run: npm run test + - run: npm run build - name: Angular 15 if: matrix.angular-version == '15.x.x' steps: - name: Run Angular 15 steps - run: npm run ng update @angular/cli@15 @angular/core@15 + - run: npm run ng update @angular/cli@15 @angular/core@15 + - run: npm run test + - run: npm run build - name: Angular 16 if: matrix.angular-version == '16.x.x' steps: - name: Run Angular 16 steps - run: npm run ng update @angular/cli@16 @angular/core@16 + - run: npm run ng update @angular/cli@16 @angular/core@16 + - run: npm run test + - run: npm run build From 1d33e4fd6c7f3ead5556573d87de03e3583c874e Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 11 Oct 2023 09:20:54 +0200 Subject: [PATCH 14/18] change on angular-version matrix --- .github/workflows/angular-versions.yaml | 55 +++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/angular-versions.yaml diff --git a/.github/workflows/angular-versions.yaml b/.github/workflows/angular-versions.yaml new file mode 100644 index 00000000..de3314e4 --- /dev/null +++ b/.github/workflows/angular-versions.yaml @@ -0,0 +1,55 @@ +name: Angular update + +on: + pull_request: + branches: [ master ] + +jobs: + update-angular: + name: Update Angular + runs-on: ubuntu-latest + + strategy: + matrix: + - angular-version: + - 14.x.x + - 15.x.x + - 16.x.x + + - node-version: + - 14.20.x + - 16.14.x + - 18.10.x + + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: Set up Node.js + - run: nvm use ${{ matrix.node-version }} + + - name: Angular 14 + if: matrix.angular-version == '14.x.x' + steps: + - name: Run Angular 14 + - run: npm run ng update @angular/cli@14 @angular/core@14 + - run: npm run test + - run: npm run build + + - name: Angular 15 + if: matrix.angular-version == '15.x.x' + steps: + - name: Run Angular 15 steps + - run: npm run ng update @angular/cli@15 @angular/core@15 + - run: npm run test + - run: npm run build + + - name: Angular 16 + if: matrix.angular-version == '16.x.x' + steps: + - name: Run Angular 16 steps + - run: npm run ng update @angular/cli@16 @angular/core@16 + - run: npm run test + - run: npm run build From 83944a8a782b275fa3dae75e68532660f6b02b16 Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 11 Oct 2023 09:27:00 +0200 Subject: [PATCH 15/18] matrix change --- .github/workflows/angular-versions.yaml | 64 ++++++++++++------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/angular-versions.yaml b/.github/workflows/angular-versions.yaml index de3314e4..073eaf1f 100644 --- a/.github/workflows/angular-versions.yaml +++ b/.github/workflows/angular-versions.yaml @@ -1,8 +1,9 @@ -name: Angular update +name: Update and Test Angular on: - pull_request: - branches: [ master ] + push: + branches: + - main jobs: update-angular: @@ -11,45 +12,44 @@ jobs: strategy: matrix: - - angular-version: - - 14.x.x - - 15.x.x - - 16.x.x - - - node-version: - - 14.20.x - - 16.14.x - - 18.10.x - - steps: + angular-version: + - '14.x.x' + - '15.x.x' + - '16.x.x' + node-version: + - '14.20.x' + - '16.14.x' + - '18.10.x' + + steps: - name: Check out code uses: actions/checkout@v2 - with: - node-version: ${{ matrix.node-version }} - name: Set up Node.js - - run: nvm use ${{ matrix.node-version }} + run: | + nvm install ${{ matrix.node-version }} + nvm use ${{ matrix.node-version }} - name: Angular 14 if: matrix.angular-version == '14.x.x' - steps: - - name: Run Angular 14 - - run: npm run ng update @angular/cli@14 @angular/core@14 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@14 @angular/core@14 + npm install + npm run test + npm run build - name: Angular 15 if: matrix.angular-version == '15.x.x' - steps: - - name: Run Angular 15 steps - - run: npm run ng update @angular/cli@15 @angular/core@15 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@15 @angular/core@15 + npm install + npm run test + npm run build - name: Angular 16 if: matrix.angular-version == '16.x.x' - steps: - - name: Run Angular 16 steps - - run: npm run ng update @angular/cli@16 @angular/core@16 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@16 @angular/core@16 + npm install + npm run test + npm run build From 20eaea009d49077fdbadb00db0d13332d23565cb Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Wed, 11 Oct 2023 10:36:06 +0200 Subject: [PATCH 16/18] angular 16 no support for node14 --- .github/workflows/angular-versions.yaml | 55 -------------- .../.github/workflows/angular-versions.yaml | 71 ++++++++++--------- 2 files changed, 39 insertions(+), 87 deletions(-) delete mode 100644 .github/workflows/angular-versions.yaml diff --git a/.github/workflows/angular-versions.yaml b/.github/workflows/angular-versions.yaml deleted file mode 100644 index 073eaf1f..00000000 --- a/.github/workflows/angular-versions.yaml +++ /dev/null @@ -1,55 +0,0 @@ -name: Update and Test Angular - -on: - push: - branches: - - main - -jobs: - update-angular: - name: Update Angular - runs-on: ubuntu-latest - - strategy: - matrix: - angular-version: - - '14.x.x' - - '15.x.x' - - '16.x.x' - node-version: - - '14.20.x' - - '16.14.x' - - '18.10.x' - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Node.js - run: | - nvm install ${{ matrix.node-version }} - nvm use ${{ matrix.node-version }} - - - name: Angular 14 - if: matrix.angular-version == '14.x.x' - run: | - npm install -g @angular/cli@14 @angular/core@14 - npm install - npm run test - npm run build - - - name: Angular 15 - if: matrix.angular-version == '15.x.x' - run: | - npm install -g @angular/cli@15 @angular/core@15 - npm install - npm run test - npm run build - - - name: Angular 16 - if: matrix.angular-version == '16.x.x' - run: | - npm install -g @angular/cli@16 @angular/core@16 - npm install - npm run test - npm run build diff --git a/packages/angular/.github/workflows/angular-versions.yaml b/packages/angular/.github/workflows/angular-versions.yaml index 274abd8f..d31be870 100644 --- a/packages/angular/.github/workflows/angular-versions.yaml +++ b/packages/angular/.github/workflows/angular-versions.yaml @@ -1,8 +1,9 @@ -name: Angular update +name: Update and Test Angular on: - pull_request: - branches: [ master ] + push: + branches: + - main jobs: update-angular: @@ -11,45 +12,51 @@ jobs: strategy: matrix: - - angular-version: - - 14.x.x - - 15.x.x - - 16.x.x - - - node-version: - - 14.20.x - - 16.14.x - - 18.10.x - - steps: + angular-version: + - '14.x.x' + - '15.x.x' + - '16.x.x' + node-version: + - '14.20.x' + - '16.14.x' + - '18.10.x' + + steps: - name: Check out code uses: actions/checkout@v2 - with: - node-version: ${{ matrix.node-version }} - name: Set up Node.js - - run: nvm use ${{ matrix.node-version }} + run: | + nvm install ${{ matrix.node-version }} + nvm use ${{ matrix.node-version }} + + + - name: Setup angular node version + if: matrix.angular-version == '16.x.x' + run: | + nvm install 16.13.0 + nvm use 16.13.0 - name: Angular 14 if: matrix.angular-version == '14.x.x' - steps: - - name: Run Angular 14 - - run: npm run install @angular/cli@14 @angular/core@14 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@14 @angular/core@14 + npm install + npm run test + npm run build - name: Angular 15 if: matrix.angular-version == '15.x.x' - steps: - - name: Run Angular 15 steps - - run: npm run ng update @angular/cli@15 @angular/core@15 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@15 @angular/core@15 + npm install + npm run test + npm run build - name: Angular 16 if: matrix.angular-version == '16.x.x' - steps: - - name: Run Angular 16 steps - - run: npm run ng update @angular/cli@16 @angular/core@16 - - run: npm run test - - run: npm run build + run: | + npm install -g @angular/cli@16 @angular/core@16 + npm install + npm run test + npm run build From c81923757e93195e6b34d2be5ed2a43f8ad30692 Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:15:16 +0100 Subject: [PATCH 17/18] need zone.js version 13 --- packages/angular/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/angular/package.json b/packages/angular/package.json index 561babb2..f8d63b6b 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -43,7 +43,7 @@ "@transifex/native": "^7.0.1", "rxjs": "~6.6.0", "tslib": "^2.6.2", - "zone.js": "^0.11.8" + "zone.js": "^0.13.3" }, "devDependencies": { "@angular-devkit/architect": "^0.1602.4", From a4df7cc19bb083f873bf12a27940252f2bd5eb5a Mon Sep 17 00:00:00 2001 From: Tse018 <60438717+tse018@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:17:05 +0100 Subject: [PATCH 18/18] only support angular 16 --- .../.github/workflows/angular-versions.yaml | 62 ------------------- .../tx-native-angular-sdk/package.json | 6 +- 2 files changed, 3 insertions(+), 65 deletions(-) delete mode 100644 packages/angular/.github/workflows/angular-versions.yaml diff --git a/packages/angular/.github/workflows/angular-versions.yaml b/packages/angular/.github/workflows/angular-versions.yaml deleted file mode 100644 index d31be870..00000000 --- a/packages/angular/.github/workflows/angular-versions.yaml +++ /dev/null @@ -1,62 +0,0 @@ -name: Update and Test Angular - -on: - push: - branches: - - main - -jobs: - update-angular: - name: Update Angular - runs-on: ubuntu-latest - - strategy: - matrix: - angular-version: - - '14.x.x' - - '15.x.x' - - '16.x.x' - node-version: - - '14.20.x' - - '16.14.x' - - '18.10.x' - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Node.js - run: | - nvm install ${{ matrix.node-version }} - nvm use ${{ matrix.node-version }} - - - - name: Setup angular node version - if: matrix.angular-version == '16.x.x' - run: | - nvm install 16.13.0 - nvm use 16.13.0 - - - name: Angular 14 - if: matrix.angular-version == '14.x.x' - run: | - npm install -g @angular/cli@14 @angular/core@14 - npm install - npm run test - npm run build - - - name: Angular 15 - if: matrix.angular-version == '15.x.x' - run: | - npm install -g @angular/cli@15 @angular/core@15 - npm install - npm run test - npm run build - - - name: Angular 16 - if: matrix.angular-version == '16.x.x' - run: | - npm install -g @angular/cli@16 @angular/core@16 - npm install - npm run test - npm run build diff --git a/packages/angular/projects/tx-native-angular-sdk/package.json b/packages/angular/projects/tx-native-angular-sdk/package.json index 76d11567..8970a573 100644 --- a/packages/angular/projects/tx-native-angular-sdk/package.json +++ b/packages/angular/projects/tx-native-angular-sdk/package.json @@ -17,8 +17,8 @@ "repository": "git://github.com/transifex/transifex-javascript.git", "license": "Apache-2.0", "peerDependencies": { - "@angular/common": "^14.0.0 || ^15.0.0 || ^16.0.0", - "@angular/core": "^14.0.0 || ^15.0.0 || ^16.0.0", - "@transifex/native": "^6.0.0" + "@angular/common": "^16.0.0", + "@angular/core": " ^16.0.0", + "@transifex/native": "^7.0.1" } }