-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Añade pruebas para formateo de fechas en español y manejo de idiomas …
…no soportados
- Loading branch information
Showing
4 changed files
with
39 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,45 @@ | ||
import { TestBed } from '@angular/core/testing' | ||
|
||
import { DateFormatterService } from './date-formatter.service' | ||
import { TranslateService } from '@ngx-translate/core' | ||
|
||
describe('DateFormatterService', () => { | ||
let service: DateFormatterService | ||
let translateService: TranslateService | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}) | ||
TestBed.configureTestingModule({ | ||
providers: [ | ||
{ | ||
provide: TranslateService, | ||
useValue: { | ||
currentLang: 'en' | ||
} | ||
} | ||
] | ||
}) | ||
service = TestBed.inject(DateFormatterService) | ||
translateService = TestBed.inject(TranslateService) | ||
}) | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy() | ||
}) | ||
|
||
it('should format date correctly in English', () => { | ||
translateService.currentLang = 'en' | ||
const date = new Date('2023-04-01') | ||
expect(service.format(date)).toEqual('April 01, 2023') | ||
}) | ||
|
||
it('should format date correctly in Spanish', () => { | ||
translateService.currentLang = 'es' | ||
const date = new Date('2023-04-01') | ||
expect(service.format(date)).toEqual('01 abril 2023') | ||
}) | ||
|
||
it('should use default pattern if language is not supported', () => { | ||
translateService.currentLang = 'fr' // French is not supported, so it should fall back to default | ||
const date = new Date('2023-04-01') | ||
expect(service.format(date)).toEqual('01 abril 2023') // Assuming default is Spanish for demonstration | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters