From dd5d25522b364a06d87f2abc226b9d6d37edda3b Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Fri, 8 Mar 2024 23:50:35 +0100 Subject: [PATCH 1/2] refactor(company)!: remove v8 deprecated company methods --- docs/guide/upgrading_v9/2726.md | 12 ++ src/definitions/company.ts | 7 - src/modules/company/index.ts | 130 ------------------ test/all-functional.spec.ts | 4 - .../__snapshots__/company.spec.ts.snap | 33 ----- test/modules/company.spec.ts | 23 ---- 6 files changed, 12 insertions(+), 197 deletions(-) create mode 100644 docs/guide/upgrading_v9/2726.md diff --git a/docs/guide/upgrading_v9/2726.md b/docs/guide/upgrading_v9/2726.md new file mode 100644 index 00000000000..577dd53bf69 --- /dev/null +++ b/docs/guide/upgrading_v9/2726.md @@ -0,0 +1,12 @@ +### Remove deprecated company methods + +Removed deprecated company methods + +| old | replacement | +| ----------------------------- | ----------------------------- | +| `faker.company.suffixes` | `faker.company.name` | +| `faker.company.companySuffix` | `faker.company.name` | +| `faker.company.bs` | `faker.company.buzzPhrase` | +| `faker.company.bsAdjective` | `faker.company.buzzAdjective` | +| `faker.company.bsBuzz` | `faker.company.buzzVerb` | +| `faker.company.bsNoun` | `faker.company.buzzNoun` | diff --git a/src/definitions/company.ts b/src/definitions/company.ts index 8a094ee9e40..578c1c07723 100644 --- a/src/definitions/company.ts +++ b/src/definitions/company.ts @@ -38,11 +38,4 @@ export type CompanyDefinition = LocaleEntry<{ * Catchphrase nouns that can be displayed to an end user. */ noun: string[]; - - /** - * Company/Business entity types. - * - * @deprecated Use `faker.company.name` instead. - */ - suffix: string[]; }>; diff --git a/src/modules/company/index.ts b/src/modules/company/index.ts index e0f79e622f8..b4e8befd79a 100644 --- a/src/modules/company/index.ts +++ b/src/modules/company/index.ts @@ -1,4 +1,3 @@ -import { deprecated } from '../../internal/deprecated'; import { ModuleBase } from '../../internal/module-base'; /** @@ -16,30 +15,6 @@ import { ModuleBase } from '../../internal/module-base'; * - For finance-related entries, use [`faker.finance`](https://fakerjs.dev/api/finance.html). */ export class CompanyModule extends ModuleBase { - /** - * Returns an array with possible company name suffixes. - * - * @see faker.company.name(): For generating a complete company name. - * - * @example - * faker.company.suffixes() // [ 'Inc', 'and Sons', 'LLC', 'Group' ] - * - * @since 2.0.1 - * - * @deprecated Use `faker.company.name` instead. - */ - suffixes(): string[] { - deprecated({ - deprecated: 'faker.company.suffixes', - proposed: 'faker.company.name', - since: '8.0', - until: '9.0', - }); - // Don't want the source array exposed to modification, so return a copy - // eslint-disable-next-line deprecation/deprecation - return [...this.faker.definitions.company.suffix]; - } - /** * Generates a random company name. * @@ -52,31 +27,6 @@ export class CompanyModule extends ModuleBase { return this.faker.helpers.fake(this.faker.definitions.company.name_pattern); } - /** - * Returns a random company suffix. - * - * @see faker.company.name(): For generating a complete company name. - * - * @example - * faker.company.companySuffix() // 'and Sons' - * - * @since 2.0.1 - * - * @deprecated Use `faker.company.name` instead. - */ - companySuffix(): string { - deprecated({ - deprecated: 'faker.company.companySuffix', - proposed: 'faker.company.name', - since: '8.0', - until: '9.0', - }); - return this.faker.helpers.arrayElement( - // eslint-disable-next-line deprecation/deprecation - this.suffixes() - ); - } - /** * Generates a random catch phrase that can be displayed to an end user. * @@ -93,26 +43,6 @@ export class CompanyModule extends ModuleBase { ].join(' '); } - /** - * Generates a random company bs phrase. - * - * @example - * faker.company.bs() // 'cultivate synergistic e-markets' - * - * @since 2.0.1 - * - * @deprecated Use `faker.company.buzzPhrase` instead. - */ - bs(): string { - deprecated({ - deprecated: 'faker.company.bs', - proposed: 'faker.company.buzzPhrase', - since: '8.0', - until: '9.0', - }); - return this.buzzPhrase(); - } - /** * Generates a random buzz phrase that can be used to demonstrate data being viewed by a manager. * @@ -165,26 +95,6 @@ export class CompanyModule extends ModuleBase { return this.faker.helpers.arrayElement(this.faker.definitions.company.noun); } - /** - * Returns a random company bs adjective. - * - * @example - * faker.company.bsAdjective() // 'one-to-one' - * - * @since 2.0.1 - * - * @deprecated Use `faker.company.buzzAdjective` instead. - */ - bsAdjective(): string { - deprecated({ - deprecated: 'faker.company.bsAdjective', - proposed: 'faker.company.buzzAdjective', - since: '8.0', - until: '9.0', - }); - return this.buzzAdjective(); - } - /** * Returns a random buzz adjective that can be used to demonstrate data being viewed by a manager. * @@ -199,26 +109,6 @@ export class CompanyModule extends ModuleBase { ); } - /** - * Returns a random company bs buzz word. - * - * @example - * faker.company.bsBuzz() // 'empower' - * - * @since 2.0.1 - * - * @deprecated Use `faker.company.buzzVerb` instead. - */ - bsBuzz(): string { - deprecated({ - deprecated: 'faker.company.bsBuzz', - proposed: 'faker.company.buzzVerb', - since: '8.0', - until: '9.0', - }); - return this.buzzVerb(); - } - /** * Returns a random buzz verb that can be used to demonstrate data being viewed by a manager. * @@ -233,26 +123,6 @@ export class CompanyModule extends ModuleBase { ); } - /** - * Returns a random company bs noun. - * - * @example - * faker.company.bsNoun() // 'paradigms' - * - * @since 2.0.1 - * - * @deprecated Use `faker.company.buzzNoun` instead. - */ - bsNoun(): string { - deprecated({ - deprecated: 'faker.company.bsNoun', - proposed: 'faker.company.buzzNoun', - since: '8.0', - until: '9.0', - }); - return this.buzzNoun(); - } - /** * Returns a random buzz noun that can be used to demonstrate data being viewed by a manager. * diff --git a/test/all-functional.spec.ts b/test/all-functional.spec.ts index 51540feb518..577e6498180 100644 --- a/test/all-functional.spec.ts +++ b/test/all-functional.spec.ts @@ -45,10 +45,6 @@ type SkipConfig = Partial< const BROKEN_LOCALE_METHODS = { // TODO @ST-DDT 2022-03-28: these are TODOs (usually broken locale files) - company: { - suffixes: ['az'], - companySuffix: ['az'], - }, date: { between: '*', betweens: '*', diff --git a/test/modules/__snapshots__/company.spec.ts.snap b/test/modules/__snapshots__/company.spec.ts.snap index a199424cb4c..26f482c3422 100644 --- a/test/modules/__snapshots__/company.spec.ts.snap +++ b/test/modules/__snapshots__/company.spec.ts.snap @@ -16,19 +16,8 @@ exports[`company > 42 > catchPhraseDescriptor 1`] = `"explicit"`; exports[`company > 42 > catchPhraseNoun 1`] = `"framework"`; -exports[`company > 42 > companySuffix 1`] = `"and Sons"`; - exports[`company > 42 > name 1`] = `"Wiegand - Reynolds"`; -exports[`company > 42 > suffixes 1`] = ` -[ - "Inc", - "and Sons", - "LLC", - "Group", -] -`; - exports[`company > 1211 > buzzAdjective 1`] = `"plug-and-play"`; exports[`company > 1211 > buzzNoun 1`] = `"methodologies"`; @@ -45,19 +34,8 @@ exports[`company > 1211 > catchPhraseDescriptor 1`] = `"upward-trending"`; exports[`company > 1211 > catchPhraseNoun 1`] = `"system engine"`; -exports[`company > 1211 > companySuffix 1`] = `"Group"`; - exports[`company > 1211 > name 1`] = `"Trantow, Fahey and Zieme"`; -exports[`company > 1211 > suffixes 1`] = ` -[ - "Inc", - "and Sons", - "LLC", - "Group", -] -`; - exports[`company > 1337 > buzzAdjective 1`] = `"global"`; exports[`company > 1337 > buzzNoun 1`] = `"ROI"`; @@ -74,15 +52,4 @@ exports[`company > 1337 > catchPhraseDescriptor 1`] = `"demand-driven"`; exports[`company > 1337 > catchPhraseNoun 1`] = `"data-warehouse"`; -exports[`company > 1337 > companySuffix 1`] = `"and Sons"`; - exports[`company > 1337 > name 1`] = `"Cronin and Sons"`; - -exports[`company > 1337 > suffixes 1`] = ` -[ - "Inc", - "and Sons", - "LLC", - "Group", -] -`; diff --git a/test/modules/company.spec.ts b/test/modules/company.spec.ts index b4a45bd623a..7e1d08d1d7b 100644 --- a/test/modules/company.spec.ts +++ b/test/modules/company.spec.ts @@ -8,9 +8,7 @@ const NON_SEEDED_BASED_RUN = 5; describe('company', () => { seededTests(faker, 'company', (t) => { t.itEach( - 'suffixes', 'name', - 'companySuffix', 'catchPhrase', 'buzzPhrase', 'catchPhraseAdjective', @@ -20,22 +18,11 @@ describe('company', () => { 'buzzVerb', 'buzzNoun' ); - - t.skip('bs').skip('bsAdjective').skip('bsBuzz').skip('bsNoun'); }); describe.each(times(NON_SEEDED_BASED_RUN).map(() => faker.seed()))( 'random seeded tests for seed %i', () => { - describe('suffixes()', () => { - it('should return all suffixes', () => { - const actual = faker.company.suffixes(); - - expect(actual).toBeTruthy(); - expect(faker.definitions.company.suffix).toEqual(actual); - }); - }); - describe('name()', () => { it('should return a random company name', () => { const actual = faker.company.name(); @@ -45,16 +32,6 @@ describe('company', () => { }); }); - describe('companySuffix()', () => { - it('should return random value from company.suffixes array', () => { - const actual = faker.company.companySuffix(); - - expect(actual).toBeTruthy(); - expect(actual).toBeTypeOf('string'); - expect(faker.definitions.company.suffix).toContain(actual); - }); - }); - describe('catchPhrase()', () => { it('should return phrase comprising of a catch phrase adjective, descriptor, and noun', () => { const actual = faker.company.catchPhrase(); From bf2cb6c0992bf8747777e6de322574941be531d1 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Sat, 9 Mar 2024 09:45:28 +0100 Subject: [PATCH 2/2] apply review suggestion --- docs/guide/upgrading_v9/2726.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/upgrading_v9/2726.md b/docs/guide/upgrading_v9/2726.md index 577dd53bf69..0d916bfdcfc 100644 --- a/docs/guide/upgrading_v9/2726.md +++ b/docs/guide/upgrading_v9/2726.md @@ -4,8 +4,8 @@ Removed deprecated company methods | old | replacement | | ----------------------------- | ----------------------------- | -| `faker.company.suffixes` | `faker.company.name` | -| `faker.company.companySuffix` | `faker.company.name` | +| `faker.company.suffixes` | Part of `faker.company.name` | +| `faker.company.companySuffix` | Part of `faker.company.name` | | `faker.company.bs` | `faker.company.buzzPhrase` | | `faker.company.bsAdjective` | `faker.company.buzzAdjective` | | `faker.company.bsBuzz` | `faker.company.buzzVerb` |