aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorShinigami <[email protected]>2023-04-18 08:21:49 +0200
committerGitHub <[email protected]>2023-04-18 08:21:49 +0200
commitfc13424b4d43bcdae6e2f2a4ffcf2130bbc357f6 (patch)
treefd66cae1b8b613bc5abdf3619c23c7fec15db4df /test
parentdb8792c8407384fdcd7fb4c2adfb0af2e5d1083e (diff)
downloadfaker-fc13424b4d43bcdae6e2f2a4ffcf2130bbc357f6.tar.xz
faker-fc13424b4d43bcdae6e2f2a4ffcf2130bbc357f6.zip
refactor(date): rename abbr to abbreviated (#2068)
Diffstat (limited to 'test')
-rw-r--r--test/__snapshots__/date.spec.ts.snap24
-rw-r--r--test/date.spec.ts51
2 files changed, 60 insertions, 15 deletions
diff --git a/test/__snapshots__/date.spec.ts.snap b/test/__snapshots__/date.spec.ts.snap
index ca3b518b..a42c8786 100644
--- a/test/__snapshots__/date.spec.ts.snap
+++ b/test/__snapshots__/date.spec.ts.snap
@@ -83,9 +83,9 @@ exports[`date > 42 > future > with value 1`] = `2024-11-19T18:52:06.785Z`;
exports[`date > 42 > month > noArgs 1`] = `"May"`;
-exports[`date > 42 > month > with abbr = true 1`] = `"May"`;
+exports[`date > 42 > month > with abbreviated = true 1`] = `"May"`;
-exports[`date > 42 > month > with abbr = true and context = true 1`] = `"May"`;
+exports[`date > 42 > month > with abbreviated = true and context = true 1`] = `"May"`;
exports[`date > 42 > month > with context = true 1`] = `"May"`;
@@ -115,9 +115,9 @@ exports[`date > 42 > soon > with value 1`] = `2021-02-25T11:02:38.995Z`;
exports[`date > 42 > weekday > noArgs 1`] = `"Tuesday"`;
-exports[`date > 42 > weekday > with abbr = true 1`] = `"Tue"`;
+exports[`date > 42 > weekday > with abbreviated = true 1`] = `"Tue"`;
-exports[`date > 42 > weekday > with abbr = true and context = true 1`] = `"Tue"`;
+exports[`date > 42 > weekday > with abbreviated = true and context = true 1`] = `"Tue"`;
exports[`date > 42 > weekday > with context = true 1`] = `"Tuesday"`;
@@ -205,9 +205,9 @@ exports[`date > 1211 > future > with value 1`] = `2030-06-03T19:31:11.467Z`;
exports[`date > 1211 > month > noArgs 1`] = `"December"`;
-exports[`date > 1211 > month > with abbr = true 1`] = `"Dec"`;
+exports[`date > 1211 > month > with abbreviated = true 1`] = `"Dec"`;
-exports[`date > 1211 > month > with abbr = true and context = true 1`] = `"Dec"`;
+exports[`date > 1211 > month > with abbreviated = true and context = true 1`] = `"Dec"`;
exports[`date > 1211 > month > with context = true 1`] = `"December"`;
@@ -237,9 +237,9 @@ exports[`date > 1211 > soon > with value 1`] = `2021-03-02T23:59:57.196Z`;
exports[`date > 1211 > weekday > noArgs 1`] = `"Saturday"`;
-exports[`date > 1211 > weekday > with abbr = true 1`] = `"Sat"`;
+exports[`date > 1211 > weekday > with abbreviated = true 1`] = `"Sat"`;
-exports[`date > 1211 > weekday > with abbr = true and context = true 1`] = `"Sat"`;
+exports[`date > 1211 > weekday > with abbreviated = true and context = true 1`] = `"Sat"`;
exports[`date > 1211 > weekday > with context = true 1`] = `"Saturday"`;
@@ -325,9 +325,9 @@ exports[`date > 1337 > future > with value 1`] = `2023-10-06T02:30:58.333Z`;
exports[`date > 1337 > month > noArgs 1`] = `"April"`;
-exports[`date > 1337 > month > with abbr = true 1`] = `"Apr"`;
+exports[`date > 1337 > month > with abbreviated = true 1`] = `"Apr"`;
-exports[`date > 1337 > month > with abbr = true and context = true 1`] = `"Apr"`;
+exports[`date > 1337 > month > with abbreviated = true and context = true 1`] = `"Apr"`;
exports[`date > 1337 > month > with context = true 1`] = `"April"`;
@@ -357,9 +357,9 @@ exports[`date > 1337 > soon > with value 1`] = `2021-02-24T08:02:25.769Z`;
exports[`date > 1337 > weekday > noArgs 1`] = `"Monday"`;
-exports[`date > 1337 > weekday > with abbr = true 1`] = `"Mon"`;
+exports[`date > 1337 > weekday > with abbreviated = true 1`] = `"Mon"`;
-exports[`date > 1337 > weekday > with abbr = true and context = true 1`] = `"Mon"`;
+exports[`date > 1337 > weekday > with abbreviated = true and context = true 1`] = `"Mon"`;
exports[`date > 1337 > weekday > with context = true 1`] = `"Monday"`;
diff --git a/test/date.spec.ts b/test/date.spec.ts
index 7ed18f47..bfa01e7d 100644
--- a/test/date.spec.ts
+++ b/test/date.spec.ts
@@ -42,10 +42,10 @@ describe('date', () => {
'month'
)((t) => {
t.it('noArgs')
- .it('with abbr = true', { abbr: true })
+ .it('with abbreviated = true', { abbreviated: true })
.it('with context = true', { context: true })
- .it('with abbr = true and context = true', {
- abbr: true,
+ .it('with abbreviated = true and context = true', {
+ abbreviated: true,
context: true,
});
});
@@ -444,12 +444,26 @@ describe('date', () => {
expect(faker.definitions.date.month.abbr).toContain(month);
});
+ it('should return random value from date.month.abbr array for abbreviated option', () => {
+ const month = faker.date.month({ abbreviated: true });
+ expect(faker.definitions.date.month.abbr).toContain(month);
+ });
+
it('should return random value from date.month.abbr_context array for abbr and context option', () => {
// Use a locale (e.g. az) which has a wide_context array
const month = fakerAZ.date.month({ abbr: true, context: true });
expect(fakerAZ.definitions.date.month.abbr_context).toContain(month);
});
+ it('should return random value from date.month.abbr_context array for abbreviated and context option', () => {
+ // Use a locale (e.g. az) which has a wide_context array
+ const month = fakerAZ.date.month({
+ abbreviated: true,
+ context: true,
+ });
+ expect(fakerAZ.definitions.date.month.abbr_context).toContain(month);
+ });
+
it('should return random value from date.month.wide array for context option when date.month.wide_context array is missing', () => {
// Use a locale (e.g. the default en) which has no wide_context array
const month = faker.date.month({ context: true });
@@ -461,6 +475,12 @@ describe('date', () => {
const month = faker.date.month({ abbr: true, context: true });
expect(faker.definitions.date.month.abbr).toContain(month);
});
+
+ it('should return random value from date.month.abbr array for abbreviated and context option when date.month.abbr_context array is missing', () => {
+ // Use a locale (e.g. the default en) which has no abbr_context array
+ const month = faker.date.month({ abbreviated: true, context: true });
+ expect(faker.definitions.date.month.abbr).toContain(month);
+ });
});
describe('weekday()', () => {
@@ -482,6 +502,11 @@ describe('date', () => {
expect(faker.definitions.date.weekday.abbr).toContain(weekday);
});
+ it('should return random value from date.weekday.abbr array for abbreviated option', () => {
+ const weekday = faker.date.weekday({ abbreviated: true });
+ expect(faker.definitions.date.weekday.abbr).toContain(weekday);
+ });
+
it('should return random value from date.weekday.abbr_context array for abbr and context option', () => {
// Use a locale (e.g. az) which has a abbr_context array
const weekday = fakerAZ.date.weekday({ abbr: true, context: true });
@@ -490,6 +515,17 @@ describe('date', () => {
);
});
+ it('should return random value from date.weekday.abbr_context array for abbreviated and context option', () => {
+ // Use a locale (e.g. az) which has a abbr_context array
+ const weekday = fakerAZ.date.weekday({
+ abbreviated: true,
+ context: true,
+ });
+ expect(fakerAZ.definitions.date.weekday.abbr_context).toContain(
+ weekday
+ );
+ });
+
it('should return random value from date.weekday.wide array for context option when date.weekday.wide_context array is missing', () => {
// Use a locale (e.g. the default en) which has no wide_context array
const weekday = faker.date.weekday({ context: true });
@@ -501,6 +537,15 @@ describe('date', () => {
const weekday = faker.date.weekday({ abbr: true, context: true });
expect(faker.definitions.date.weekday.abbr).toContain(weekday);
});
+
+ it('should return random value from date.weekday.abbr array for abbreviated and context option when date.weekday.abbr_context array is missing', () => {
+ // Use a locale (e.g. the default en) which has no abbr_context array
+ const weekday = faker.date.weekday({
+ abbreviated: true,
+ context: true,
+ });
+ expect(faker.definitions.date.weekday.abbr).toContain(weekday);
+ });
});
describe('birthdate', () => {