Skip to content

Commit

Permalink
test: improve expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Jun 20, 2024
1 parent 2ea1cfb commit 4527b50
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion test/modules/date.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,11 @@ describe('date', () => {

describe('definitions', () => {
describe('timeZone', () => {
// date.timezone data should only be available in the base locale
it('should have timezones in the base locale', () => {
expect(allLocales.base.date?.time_zone).toSatisfy(Array.isArray);
expect(allLocales.base.date?.time_zone?.length).toBeGreaterThan(0);
});

it.each(
Object.entries(allLocales).filter(([locale]) => locale !== 'base')
)('should not have any timezones in %s', (_, data) => {
Expand Down
6 changes: 5 additions & 1 deletion test/modules/location.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,17 @@ describe('definitions', () => {
'locale data for %s should be a subset of the base locale',
(locale, data) => {
if (locale === 'base') {
expect(data.location?.time_zone).toSatisfy(Array.isArray);
expect(data.location?.time_zone?.length).toBeGreaterThan(0);
expect(data.location?.time_zone).toEqual(
allLocales.base.date?.time_zone
);
} else if (data.location?.time_zone != null) {
expect(data.location.time_zone).toSatisfy(Array.isArray);
expect(data.location.time_zone.length).toBeGreaterThan(0);
// expected and actual are flipped here
expect(allLocales.base.date?.time_zone).toEqual(
expect.arrayContaining(data.location?.time_zone)
expect.arrayContaining(data.location.time_zone)
);
}
}
Expand Down

0 comments on commit 4527b50

Please sign in to comment.