Skip to content

Commit

Permalink
Merge pull request #29 from prasetyodimas/feat/ci-cd
Browse files Browse the repository at this point in the history
[PR] Feat/ci cd
  • Loading branch information
prasetyodimas authored Apr 2, 2024
2 parents c99d773 + 12ef06a commit 10a69a3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 16.20.2

Expand All @@ -31,11 +31,9 @@ jobs:
id: unit-tests
run: |
if npm run test:ci; then
echo "Tests passed"
echo "::set-output name=status::success"
echo "{name}={value}" >> $GITHUB_STATE
else
echo "Tests failed"
echo "::set-output name=status::failure"
echo "{name}={value}" >> $GITHUB_OUTPUT
fi
- name: Check test status
Expand Down
34 changes: 30 additions & 4 deletions src/app/core/lang/lang.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TestBed } from '@angular/core/testing';
import { TranslateService, TranslateModule } from '@ngx-translate/core';
import { LangService } from './lang.service';
import { environment } from 'src/environments/environment.dev';

describe('LangService', () => {
let service: LangService;
Expand Down Expand Up @@ -32,19 +33,20 @@ describe('LangService', () => {
});

it('should switch language', () => {
const useSpy = spyOn(translateService, 'use');
const lang = 'en_US';
spyOn(translateService, 'use');

service.switchLang('en_US');
service.switchLang(lang);

expect(useSpy).toHaveBeenCalledWith('en_US');
expect(translateService.use).toHaveBeenCalledWith(lang);
});

it('should add custom event', () => {
spyOn(window, 'addEventListener');

service.addCustomEvent();

expect(window.addEventListener).toHaveBeenCalled();
expect(window.addEventListener).toHaveBeenCalledWith("CHANGE_LANGUAGE", jasmine.any(Function));
});

it('should remove custom event', () => {
Expand All @@ -64,4 +66,28 @@ describe('LangService', () => {
expect(translateServiceSpy).toHaveBeenCalledWith('en_US');
});


it('should log language setting when debug mode is enabled', () => {
environment.debug.lang = true;
const moduleName = 'TestModule';
const langChangeEvent = { lang: 'en_US' } as any;

spyOn(console, 'info');

service.logLangSetting(moduleName, langChangeEvent);

expect(console.info).toHaveBeenCalledWith(`Initialize Lang ==> ${moduleName} Module`, langChangeEvent);
});

it('should not log language setting when debug mode is disabled', () => {
environment.debug.lang = false;
const moduleName = 'TestModule';
const langChangeEvent = { lang: 'en_US' } as any;

spyOn(console, 'info');

service.logLangSetting(moduleName, langChangeEvent);
expect(console.info).not.toHaveBeenCalled();
});

});

0 comments on commit 10a69a3

Please sign in to comment.