From 116f0bc5bd4c14034f57070f3348b7c5142625d2 Mon Sep 17 00:00:00 2001 From: mollykreis <20542556+mollykreis@users.noreply.github.com> Date: Fri, 26 Apr 2024 15:53:41 -0500 Subject: [PATCH] Add parameterize suite (#2037) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Pull Request ## ๐Ÿคจ Rationale Create `parameterizeSuite` function within `jasmine-parameterize` package. Resolves #1827 ## ๐Ÿ‘ฉโ€๐Ÿ’ป Implementation - Refactored the existing internal `parameterize` function within `jasmine-parameterize` so that it can be called for specs and suites - Create `parameterizeSuite` function within `jasmine-parameterize` package - Leverage the new `parameterizeSuite` function in one place within `nimble-components` ## ๐Ÿงช Testing - Extended the testing of `parameterize` to cover both spec and suite usages - Copied the `parameterizeSpec` tests and adapted for testing `parameterizeSuite` - Made sure the `parameterizeSuite` function worked as expected by using it within the `nimble-select` tests ## โœ… Checklist - [ ] I have updated the project documentation to reflect my changes or determined no changes are needed. --------- Co-authored-by: Milan Raj --- ...-544a8033-fa3b-4201-872c-b6f070a48513.json | 7 + ...-d6494d37-cc3a-4756-9bb7-c4a8ea4d89c7.json | 7 + packages/jasmine-parameterized/README.md | 34 ++++ packages/jasmine-parameterized/src/index.ts | 3 +- .../src/parameterize-spec.ts | 51 ++++++ .../src/parameterize-suite.ts | 56 +++++++ .../jasmine-parameterized/src/parameterize.ts | 84 ++++++++++ .../src/parameterized.ts | 126 --------------- .../src/tests/parameterize-spec.spec.ts | 125 +++++++++++++++ .../src/tests/parameterize-suite.spec.ts | 125 +++++++++++++++ ...meterized.spec.ts => parameterize.spec.ts} | 148 ++++++++++-------- packages/jasmine-parameterized/src/types.ts | 33 ++++ .../src/menu-button/tests/menu-button.spec.ts | 75 ++++----- .../src/select/tests/select.spec.ts | 17 +- .../icon/tests/table-column-icon.spec.ts | 22 ++- 15 files changed, 662 insertions(+), 251 deletions(-) create mode 100644 change/@ni-jasmine-parameterized-544a8033-fa3b-4201-872c-b6f070a48513.json create mode 100644 change/@ni-nimble-components-d6494d37-cc3a-4756-9bb7-c4a8ea4d89c7.json create mode 100644 packages/jasmine-parameterized/src/parameterize-spec.ts create mode 100644 packages/jasmine-parameterized/src/parameterize-suite.ts create mode 100644 packages/jasmine-parameterized/src/parameterize.ts delete mode 100644 packages/jasmine-parameterized/src/parameterized.ts create mode 100644 packages/jasmine-parameterized/src/tests/parameterize-spec.spec.ts create mode 100644 packages/jasmine-parameterized/src/tests/parameterize-suite.spec.ts rename packages/jasmine-parameterized/src/tests/{parameterized.spec.ts => parameterize.spec.ts} (59%) create mode 100644 packages/jasmine-parameterized/src/types.ts diff --git a/change/@ni-jasmine-parameterized-544a8033-fa3b-4201-872c-b6f070a48513.json b/change/@ni-jasmine-parameterized-544a8033-fa3b-4201-872c-b6f070a48513.json new file mode 100644 index 0000000000..0bd4a9931e --- /dev/null +++ b/change/@ni-jasmine-parameterized-544a8033-fa3b-4201-872c-b6f070a48513.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "Create `parameterizeSuite` function", + "packageName": "@ni/jasmine-parameterized", + "email": "20542556+mollykreis@users.noreply.github.com", + "dependentChangeType": "patch" +} diff --git a/change/@ni-nimble-components-d6494d37-cc3a-4756-9bb7-c4a8ea4d89c7.json b/change/@ni-nimble-components-d6494d37-cc3a-4756-9bb7-c4a8ea4d89c7.json new file mode 100644 index 0000000000..a7e8ee7e49 --- /dev/null +++ b/change/@ni-nimble-components-d6494d37-cc3a-4756-9bb7-c4a8ea4d89c7.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "Update tests to use `parameterizeSuite`", + "packageName": "@ni/nimble-components", + "email": "20542556+mollykreis@users.noreply.github.com", + "dependentChangeType": "none" +} diff --git a/packages/jasmine-parameterized/README.md b/packages/jasmine-parameterized/README.md index c8bc5a791b..5a3fe2b0f9 100644 --- a/packages/jasmine-parameterized/README.md +++ b/packages/jasmine-parameterized/README.md @@ -40,3 +40,37 @@ describe('Different rains', () => { }); }); ``` + +### `parameterizeSuite` + +Use `parameterizeSuite` to create a parameterized test suite using an array of test scenarios with names. + +In the following example: + + - the suite named `cats-and-dogs` is focused for debugging + - the suite named `frogs` is configured to always be disabled + - the suite named `men` will run normally as it has no override + +```ts +import { parameterizeSuite } from '@ni/jasmine-parameterized'; +const rainTests = [ + { name: 'cats-and-dogs', type: 'idiom' }, + { name: 'frogs' type: 'idiom'}, + { name: 'men', type: 'lyrics'} +] as const; +parameterizeSuite(rainTests, (suite, name, value) => { + suite(`with ${name}`, () => { + it('expect type to be defined', () => { + expect(value.type).toBeDefined(); + }); + + it('expect type to have a non-zero length', () => { + const length = value.type.length; + expect(length).toBeGreaterThan(0); + }); + }); +}, { + 'cats-and-dogs': fdescribe, + frogs: xdescribe +}); +``` diff --git a/packages/jasmine-parameterized/src/index.ts b/packages/jasmine-parameterized/src/index.ts index 1c4c15f02e..b719555fd9 100644 --- a/packages/jasmine-parameterized/src/index.ts +++ b/packages/jasmine-parameterized/src/index.ts @@ -1 +1,2 @@ -export { parameterizeSpec } from './parameterized.js'; +export { parameterizeSpec } from './parameterize-spec.js'; +export { parameterizeSuite } from './parameterize-suite.js'; diff --git a/packages/jasmine-parameterized/src/parameterize-spec.ts b/packages/jasmine-parameterized/src/parameterize-spec.ts new file mode 100644 index 0000000000..556072d012 --- /dev/null +++ b/packages/jasmine-parameterized/src/parameterize-spec.ts @@ -0,0 +1,51 @@ +import { parameterize } from './parameterize.js'; +import { ObjectFromNamedList, Spec, SpecOverride } from './types.js'; + +/** + * Used to create a parameterized test using an array of tests with names. + * In the following example: + * - the test named `cats-and-dogs` is focused for debugging + * - the test named `frogs` is configured to always be disabled + * - the test named `men` will run normally as it has no override + * @example + * const rainTests = [ + * { name: 'cats-and-dogs', type: 'idiom' }, + * { name: 'frogs' type: 'idiom'}, + * { name: 'men', type: 'lyrics'} + * ] as const; + * describe('Different rains', () => { + * parameterizeSpec(rainTests, (spec, name, value) => { + * spec(`of type ${name} exist`, () => { + * expect(value.type).toBeDefined(); + * }); + * }, { + * 'cats-and-dogs': fit, + * frogs: xit + * }); + * }); + */ +export const parameterizeSpec = ( + list: T, + test: ( + spec: Spec, + name: keyof ObjectFromNamedList, + value: T[number] + ) => void, + specOverrides?: { + [P in keyof ObjectFromNamedList]?: SpecOverride; + } +): void => { + const testCases = list.reduce<{ [key: string]: { name: string } }>( + (result, entry) => { + if (result[entry.name]) { + throw new Error( + `Duplicate name found in test case list: ${entry.name}. Make sure all test names are unique.` + ); + } + result[entry.name] = entry; + return result; + }, + {} + ) as ObjectFromNamedList; + parameterize>('spec', testCases, test, specOverrides); +}; diff --git a/packages/jasmine-parameterized/src/parameterize-suite.ts b/packages/jasmine-parameterized/src/parameterize-suite.ts new file mode 100644 index 0000000000..02bc963fdc --- /dev/null +++ b/packages/jasmine-parameterized/src/parameterize-suite.ts @@ -0,0 +1,56 @@ +import { parameterize } from './parameterize.js'; +import { ObjectFromNamedList, Suite, SuiteOverride } from './types.js'; + +/** + * Used to create a parameterized suite using an array of test scenarios with names. + * In the following example: + * - the suite named `cats-and-dogs` is focused for debugging + * - the suite named `frogs` is configured to always be disabled + * - the suite named `men` will run normally as it has no override + * @example +* const rainTests = [ +* { name: 'cats-and-dogs', type: 'idiom' }, +* { name: 'frogs' type: 'idiom'}, +* { name: 'men', type: 'lyrics'} +* ] as const; +* parameterizeSuite(rainTests, (suite, name, value) => { +* suite(`with ${name}`, () => { +* it('expect type to be defined', () => { +* expect(value.type).toBeDefined(); +* }); +* +* it('expect type to have a non-zero length', () => { +* const length = value.type.length; +* expect(length).toBeGreaterThan(0); +* }); +* }); +* }, { +* 'cats-and-dogs': fdescribe, +* frogs: xdescribe +* }); +*/ +export const parameterizeSuite = ( + list: T, + test: ( + suite: Suite, + name: keyof ObjectFromNamedList, + value: T[number] + ) => void, + specOverrides?: { + [P in keyof ObjectFromNamedList]?: SuiteOverride; + } +): void => { + const testCases = list.reduce<{ [key: string]: { name: string } }>( + (result, entry) => { + if (result[entry.name]) { + throw new Error( + `Duplicate name found in test suite list: ${entry.name}. Make sure all test suite names are unique.` + ); + } + result[entry.name] = entry; + return result; + }, + {} + ) as ObjectFromNamedList; + parameterize>('suite', testCases, test, specOverrides); +}; diff --git a/packages/jasmine-parameterized/src/parameterize.ts b/packages/jasmine-parameterized/src/parameterize.ts new file mode 100644 index 0000000000..60c7176211 --- /dev/null +++ b/packages/jasmine-parameterized/src/parameterize.ts @@ -0,0 +1,84 @@ +import { Spec, SpecOverride, Suite, SuiteOverride } from './types.js'; + +/** + * Used to create a parameterized test or suite using an object of names and arbitrary test values. + * In the following example: + * - the test named `catsAndDogs` is focused for debugging + * - the test named `frogs` is configured to always be disabled + * - the test named `men` will run normally as it has no override + * @example + * const rainTests = { + * catsAndDogs: 'idiom', + * frogs: 'idiom', + * men: 'lyrics' + * } as const; + * describe('Different rains', () => { + * parameterize('spec', rainTests, (spec, name, value) => { + * spec(`of type ${name} exist`, () => { + * expect(value).toBeDefined(); + * }); + * }, { + * catsAndDogs: fit, + * frogs: xit + * }); + * }); + */ +export function parameterize( + testType: 'spec', + testCases: T, + test: (spec: Spec, name: keyof T, value: T[keyof T]) => void, + overrides?: { + [P in keyof T]?: SpecOverride; + } +): void; +export function parameterize( + testType: 'suite', + testCases: T, + test: (spec: Suite, name: keyof T, value: T[keyof T]) => void, + overrides?: { + [P in keyof T]?: SuiteOverride; + } +): void; +export function parameterize( + testType: 'spec' | 'suite', + testCases: T, + test: (spec: U, name: keyof T, value: T[keyof T]) => void, + overrides?: { + [P in keyof T]?: U extends Spec ? SpecOverride : SuiteOverride; + } +): void { + const testCaseNames = Object.keys(testCases) as (keyof T)[]; + if (overrides) { + const overrideNames = Object.keys( + overrides + ) as (keyof typeof overrides)[]; + if ( + !overrideNames.every(overrideName => testCaseNames.includes(overrideName)) + ) { + throw new Error( + 'Parameterized test override names must match test case name' + ); + } + if ( + testType === 'spec' + // eslint-disable-next-line no-restricted-globals + && !overrideNames.every(overrideName => [fit, xit].includes(overrides[overrideName] as Spec)) + ) { + throw new Error('Must configure override with one of the jasmine spec functions: fit or xit'); + } + if ( + testType === 'suite' + // eslint-disable-next-line no-restricted-globals + && !overrideNames.every(overrideName => [fdescribe, xdescribe].includes(overrides[overrideName] as Suite)) + ) { + throw new Error( + 'Must configure override with one of the jasmine suite functions: fdescribe or xdescribe' + ); + } + } + testCaseNames.forEach(testCaseName => { + const defaultTest = testType === 'spec' ? it : describe; + const spec = overrides?.[testCaseName] ?? defaultTest; + test(spec as U, testCaseName, testCases[testCaseName]); + }); +} \ No newline at end of file diff --git a/packages/jasmine-parameterized/src/parameterized.ts b/packages/jasmine-parameterized/src/parameterized.ts deleted file mode 100644 index c0cd7d7a91..0000000000 --- a/packages/jasmine-parameterized/src/parameterized.ts +++ /dev/null @@ -1,126 +0,0 @@ -// The following aliases are just to reduce the number -// of eslint disables in this source file. In normal -// test code use the globals directly so eslint can -// guard accidental check-ins of fit, etc. -// eslint-disable-next-line no-restricted-globals -type Fit = typeof fit; -type Xit = typeof xit; -type It = typeof it; -/** - * One of the jasmine spec functions: fit, xit, or it - */ -type Spec = Fit | Xit | It; -/** - * One of the jasmine spec functions: fit or xit - */ -type SpecOverride = Fit | Xit; - -/** - * Used to create a parameterized test using an object of test names and arbitrary test values. - * In the following example: - * - the test named `catsAndDogs` is focused for debugging - * - the test named `frogs` is configured to always be disabled - * - the test named `men` will run normally as it has no override - * @example - * const rainTests = { - * catsAndDogs: 'idiom', - * frogs: 'idiom', - * men: 'lyrics' - * } as const; - * describe('Different rains', () => { - * parameterize(rainTests, (spec, name, value) => { - * spec(`of type ${name} exist`, () => { - * expect(value).toBeDefined(); - * }); - * }, { - * catsAndDogs: fit, - * frogs: xit - * }); - * }); - */ -export const parameterize = ( - testCases: T, - test: (spec: Spec, name: keyof T, value: T[keyof T]) => void, - specOverrides?: { - [P in keyof T]?: SpecOverride; - } -): void => { - const testCaseNames = Object.keys(testCases) as (keyof T)[]; - if (specOverrides) { - const overrideNames = Object.keys( - specOverrides - ) as (keyof typeof specOverrides)[]; - if ( - !overrideNames.every(overrideName => testCaseNames.includes(overrideName)) - ) { - throw new Error( - 'Parameterized test override names must match test case name' - ); - } - if ( - // eslint-disable-next-line no-restricted-globals - !overrideNames.every(overrideName => [fit, xit].includes(specOverrides[overrideName]!)) - ) { - throw new Error( - 'Must configure override with one of the jasmine spec functions: fit or xit' - ); - } - } - testCaseNames.forEach(testCaseName => { - const spec = specOverrides?.[testCaseName] ?? it; - test(spec, testCaseName, testCases[testCaseName]); - }); -}; - -type ObjectFromNamedList = { - [K in T extends readonly { name: infer U }[] ? U : never]: T[number]; -}; - -/** - * Used to create a parameterized test using an array of tests with names. - * In the following example: - * - the test named `cats-and-dogs` is focused for debugging - * - the test named `frogs` is configured to always be disabled - * - the test named `men` will run normally as it has no override - * @example - * const rainTests = [ - * { name: 'cats-and-dogs', type: 'idiom' }, - * { name: 'frogs', type: 'idiom'}, - * { name: 'men', type: 'lyrics'} - * ] as const; - * describe('Different rains', () => { - * parameterizeSpec(rainTests, (spec, name, value) => { - * spec(`of type ${name} exist`, () => { - * expect(value.type).toBeDefined(); - * }); - * }, { - * 'cats-and-dogs': fit, - * frogs: xit - * }); - * }); - */ -export const parameterizeSpec = ( - list: T, - test: ( - spec: Spec, - name: keyof ObjectFromNamedList, - value: T[number] - ) => void, - specOverrides?: { - [P in keyof ObjectFromNamedList]?: SpecOverride; - } -): void => { - const testCases = list.reduce<{ [key: string]: { name: string } }>( - (result, entry) => { - if (result[entry.name]) { - throw new Error( - `Duplicate name found in test case list: ${entry.name}. Make sure all test names are unique.` - ); - } - result[entry.name] = entry; - return result; - }, - {} - ) as ObjectFromNamedList; - parameterize>(testCases, test, specOverrides); -}; diff --git a/packages/jasmine-parameterized/src/tests/parameterize-spec.spec.ts b/packages/jasmine-parameterized/src/tests/parameterize-spec.spec.ts new file mode 100644 index 0000000000..1f038227dd --- /dev/null +++ b/packages/jasmine-parameterized/src/tests/parameterize-spec.spec.ts @@ -0,0 +1,125 @@ +import { parameterizeSpec } from '../parameterize-spec.js'; + +// The following aliases are just to reduce the number +// of eslint disables in this test file. In normal +// test code use the globals directly so eslint can +// guard accidental check-ins of fit, etc. +// eslint-disable-next-line no-restricted-globals +const FIT = fit; +const IT = it; +const XIT = xit; + +interface ParameterizeListTestArgs { + spec: typeof IT | typeof XIT | typeof FIT; + name: string; +} +const paramertizeListTestArgs = ([ + spec, + name +]: unknown[]): ParameterizeListTestArgs => ({ + spec, + name +} as ParameterizeListTestArgs); + +describe('Function parameterizeSpec', () => { + describe('can parameterize simple lists', () => { + it('with test enabled', () => { + const testcases = [{ name: 'case1' }] as const; + const spy = jasmine.createSpy(); + parameterizeSpec(testcases, spy); + + expect(spy).toHaveBeenCalledTimes(1); + const { spec, name } = paramertizeListTestArgs( + spy.calls.argsFor(0) + ); + expect(spec).toBe(IT); + expect(name).toBe('case1'); + }); + + it('with test focused', () => { + const testcases = [{ name: 'case1' }] as const; + const spy = jasmine.createSpy(); + parameterizeSpec(testcases, spy, { + case1: FIT + }); + + expect(spy).toHaveBeenCalledTimes(1); + const { spec, name } = paramertizeListTestArgs( + spy.calls.argsFor(0) + ); + expect(spec).toBe(FIT); + expect(name).toBe('case1'); + }); + + it('with test disabled', () => { + const testcases = [{ name: 'case1' }] as const; + const spy = jasmine.createSpy(); + parameterizeSpec(testcases, spy, { + case1: XIT + }); + + expect(spy).toHaveBeenCalledTimes(1); + const { spec, name } = paramertizeListTestArgs( + spy.calls.argsFor(0) + ); + expect(spec).toBe(XIT); + expect(name).toBe('case1'); + }); + + it('with various test cases enabled and disabled', () => { + const testcases = [ + { name: 'case1' }, + { name: 'case2' }, + { name: 'case3' } + ] as const; + const spy = jasmine.createSpy(); + parameterizeSpec(testcases, spy, { + case2: XIT, + case3: FIT + }); + + expect(spy).toHaveBeenCalledTimes(3); + { + const { spec, name } = paramertizeListTestArgs( + spy.calls.argsFor(0) + ); + expect(spec).toBe(IT); + expect(name).toBe('case1'); + } + { + const { spec, name } = paramertizeListTestArgs( + spy.calls.argsFor(1) + ); + expect(spec).toBe(XIT); + expect(name).toBe('case2'); + } + { + const { spec, name } = paramertizeListTestArgs( + spy.calls.argsFor(2) + ); + expect(spec).toBe(FIT); + expect(name).toBe('case3'); + } + }); + }); + describe('errors', () => { + it('for override not in test cases', () => { + const testcases = [{ name: 'case1' }] as { name: string }[]; + + expect(() => { + parameterizeSpec(testcases, () => {}, { + unknown: XIT + }); + }).toThrowError(/override names must match test case name/); + }); + it('for override not referencing supported xit or fit', () => { + const testcases = [{ name: 'case1' }] as const; + + expect(() => { + parameterizeSpec(testcases, () => {}, { + case1: IT + }); + }).toThrowError(/jasmine spec functions: fit or xit/); + }); + }); +}); diff --git a/packages/jasmine-parameterized/src/tests/parameterize-suite.spec.ts b/packages/jasmine-parameterized/src/tests/parameterize-suite.spec.ts new file mode 100644 index 0000000000..35a69f9f0d --- /dev/null +++ b/packages/jasmine-parameterized/src/tests/parameterize-suite.spec.ts @@ -0,0 +1,125 @@ +import { parameterizeSuite } from '../parameterize-suite.js'; + +// The following aliases are just to reduce the number +// of eslint disables in this test file. In normal +// test code use the globals directly so eslint can +// guard accidental check-ins of fit, etc. +// eslint-disable-next-line no-restricted-globals +const FDESCRIBE = fdescribe; +const DESCRIBE = describe; +const XDESCRIBE = xdescribe; + +interface ParameterizeListTestArgs { + suite: typeof DESCRIBE | typeof XDESCRIBE | typeof FDESCRIBE; + name: string; +} +const paramertizeListTestArgs = ([ + suite, + name +]: unknown[]): ParameterizeListTestArgs => ({ + suite, + name +} as ParameterizeListTestArgs); + +describe('Function parameterizeSuite', () => { + describe('can parameterize simple lists', () => { + it('with test enabled', () => { + const testcases = [{ name: 'case1' }] as const; + const spy = jasmine.createSpy(); + parameterizeSuite(testcases, spy); + + expect(spy).toHaveBeenCalledTimes(1); + const { suite, name } = paramertizeListTestArgs( + spy.calls.argsFor(0) + ); + expect(suite).toBe(DESCRIBE); + expect(name).toBe('case1'); + }); + + it('with test focused', () => { + const testcases = [{ name: 'case1' }] as const; + const spy = jasmine.createSpy(); + parameterizeSuite(testcases, spy, { + case1: FDESCRIBE + }); + + expect(spy).toHaveBeenCalledTimes(1); + const { suite, name } = paramertizeListTestArgs( + spy.calls.argsFor(0) + ); + expect(suite).toBe(FDESCRIBE); + expect(name).toBe('case1'); + }); + + it('with test disabled', () => { + const testcases = [{ name: 'case1' }] as const; + const spy = jasmine.createSpy(); + parameterizeSuite(testcases, spy, { + case1: XDESCRIBE + }); + + expect(spy).toHaveBeenCalledTimes(1); + const { suite, name } = paramertizeListTestArgs( + spy.calls.argsFor(0) + ); + expect(suite).toBe(XDESCRIBE); + expect(name).toBe('case1'); + }); + + it('with various test cases enabled and disabled', () => { + const testcases = [ + { name: 'case1' }, + { name: 'case2' }, + { name: 'case3' } + ] as const; + const spy = jasmine.createSpy(); + parameterizeSuite(testcases, spy, { + case2: XDESCRIBE, + case3: FDESCRIBE + }); + + expect(spy).toHaveBeenCalledTimes(3); + { + const { suite, name } = paramertizeListTestArgs( + spy.calls.argsFor(0) + ); + expect(suite).toBe(DESCRIBE); + expect(name).toBe('case1'); + } + { + const { suite, name } = paramertizeListTestArgs( + spy.calls.argsFor(1) + ); + expect(suite).toBe(XDESCRIBE); + expect(name).toBe('case2'); + } + { + const { suite, name } = paramertizeListTestArgs( + spy.calls.argsFor(2) + ); + expect(suite).toBe(FDESCRIBE); + expect(name).toBe('case3'); + } + }); + }); + describe('errors', () => { + it('for override not in test cases', () => { + const testcases = [{ name: 'case1' }] as { name: string }[]; + + expect(() => { + parameterizeSuite(testcases, () => {}, { + unknown: XDESCRIBE + }); + }).toThrowError(/override names must match test case name/); + }); + it('for override not referencing supported xit or fit', () => { + const testcases = [{ name: 'case1' }] as const; + + expect(() => { + parameterizeSuite(testcases, () => {}, { + case1: DESCRIBE + }); + }).toThrowError(/jasmine suite functions: fdescribe or xdescribe/); + }); + }); +}); diff --git a/packages/jasmine-parameterized/src/tests/parameterized.spec.ts b/packages/jasmine-parameterized/src/tests/parameterize.spec.ts similarity index 59% rename from packages/jasmine-parameterized/src/tests/parameterized.spec.ts rename to packages/jasmine-parameterized/src/tests/parameterize.spec.ts index 5af4efb8dc..03c50baa05 100644 --- a/packages/jasmine-parameterized/src/tests/parameterized.spec.ts +++ b/packages/jasmine-parameterized/src/tests/parameterize.spec.ts @@ -1,4 +1,4 @@ -import { parameterize, parameterizeSpec } from '../parameterized.js'; +import { parameterize } from '../parameterize.js'; // The following aliases are just to reduce the number // of eslint disables in this test file. In normal @@ -9,32 +9,32 @@ const FIT = fit; const IT = it; const XIT = xit; -interface ParameterizeTestArgs { +interface ParameterizeSpecTestArgs { spec: typeof IT | typeof XIT | typeof FIT; name: string; value: unknown; } -const paramertizeTestArgs = ([ +const paramertizeSpecTestArgs = ([ spec, name, value -]: unknown[]): ParameterizeTestArgs => ({ +]: unknown[]): ParameterizeSpecTestArgs => ({ spec, name, value -} as ParameterizeTestArgs); +} as ParameterizeSpecTestArgs); -describe('Funtion parameterize', () => { +describe('Function parameterize with specs', () => { describe('can parameterize simple objects', () => { it('with test enabled', () => { const testcases = { case1: 'one' } as const; const spy = jasmine.createSpy(); - parameterize(testcases, spy); + parameterize('spec', testcases, spy); expect(spy).toHaveBeenCalledTimes(1); - const { spec, name, value } = paramertizeTestArgs( + const { spec, name, value } = paramertizeSpecTestArgs( spy.calls.argsFor(0) ); expect(spec).toBe(IT); @@ -47,12 +47,12 @@ describe('Funtion parameterize', () => { case1: 'one' } as const; const spy = jasmine.createSpy(); - parameterize(testcases, spy, { + parameterize('spec', testcases, spy, { case1: FIT }); expect(spy).toHaveBeenCalledTimes(1); - const { spec, name, value } = paramertizeTestArgs( + const { spec, name, value } = paramertizeSpecTestArgs( spy.calls.argsFor(0) ); expect(spec).toBe(FIT); @@ -65,12 +65,12 @@ describe('Funtion parameterize', () => { case1: 'one' } as const; const spy = jasmine.createSpy(); - parameterize(testcases, spy, { + parameterize('spec', testcases, spy, { case1: XIT }); expect(spy).toHaveBeenCalledTimes(1); - const { spec, name, value } = paramertizeTestArgs( + const { spec, name, value } = paramertizeSpecTestArgs( spy.calls.argsFor(0) ); expect(spec).toBe(XIT); @@ -85,14 +85,14 @@ describe('Funtion parameterize', () => { case3: 'three' } as const; const spy = jasmine.createSpy(); - parameterize(testcases, spy, { + parameterize('spec', testcases, spy, { case2: XIT, case3: FIT }); expect(spy).toHaveBeenCalledTimes(3); { - const { spec, name, value } = paramertizeTestArgs( + const { spec, name, value } = paramertizeSpecTestArgs( spy.calls.argsFor(0) ); expect(spec).toBe(IT); @@ -100,7 +100,7 @@ describe('Funtion parameterize', () => { expect(value).toBe('one'); } { - const { spec, name, value } = paramertizeTestArgs( + const { spec, name, value } = paramertizeSpecTestArgs( spy.calls.argsFor(1) ); expect(spec).toBe(XIT); @@ -108,7 +108,7 @@ describe('Funtion parameterize', () => { expect(value).toBe('two'); } { - const { spec, name, value } = paramertizeTestArgs( + const { spec, name, value } = paramertizeSpecTestArgs( spy.calls.argsFor(2) ); expect(spec).toBe(FIT); @@ -124,7 +124,7 @@ describe('Funtion parameterize', () => { } as { [key: string]: string }; expect(() => { - parameterize(testcases, () => {}, { + parameterize('spec', testcases, () => {}, { unknown: XIT }); }).toThrowError(/override names must match test case name/); @@ -135,7 +135,7 @@ describe('Funtion parameterize', () => { } as const; expect(() => { - parameterize(testcases, () => {}, { + parameterize('spec', testcases, () => {}, { case1: IT }); }).toThrowError(/jasmine spec functions: fit or xit/); @@ -143,117 +143,141 @@ describe('Funtion parameterize', () => { }); }); -interface ParameterizeListTestArgs { - spec: typeof IT | typeof XIT | typeof FIT; +// eslint-disable-next-line no-restricted-globals +const FDESCRIBE = fdescribe; +const DESCRIBE = describe; +const XDESCRIBE = xdescribe; + +interface ParameterizeSuiteTestArgs { + spec: typeof DESCRIBE | typeof XDESCRIBE | typeof FDESCRIBE; name: string; + value: unknown; } -const paramertizeListTestArgs = ([ +const parameterizeSuiteTestArgs = ([ spec, - name -]: unknown[]): ParameterizeListTestArgs => ({ + name, + value +]: unknown[]): ParameterizeSuiteTestArgs => ({ spec, - name -} as ParameterizeListTestArgs); + name, + value +} as ParameterizeSuiteTestArgs); -describe('Funtion parameterizeSpec', () => { - describe('can parameterize simple lists', () => { +describe('Function parameterize with suites', () => { + describe('can parameterize simple objects', () => { it('with test enabled', () => { - const testcases = [{ name: 'case1' }] as const; + const testcases = { + case1: 'one' + } as const; const spy = jasmine.createSpy(); - parameterizeSpec(testcases, spy); + parameterize('suite', testcases, spy); expect(spy).toHaveBeenCalledTimes(1); - const { spec, name } = paramertizeListTestArgs( + const { spec, name, value } = parameterizeSuiteTestArgs( spy.calls.argsFor(0) ); - expect(spec).toBe(IT); + expect(spec).toBe(DESCRIBE); expect(name).toBe('case1'); + expect(value).toBe('one'); }); it('with test focused', () => { - const testcases = [{ name: 'case1' }] as const; + const testcases = { + case1: 'one' + } as const; const spy = jasmine.createSpy(); - parameterizeSpec(testcases, spy, { - case1: FIT + parameterize('suite', testcases, spy, { + case1: FDESCRIBE }); expect(spy).toHaveBeenCalledTimes(1); - const { spec, name } = paramertizeListTestArgs( + const { spec, name, value } = parameterizeSuiteTestArgs( spy.calls.argsFor(0) ); - expect(spec).toBe(FIT); + expect(spec).toBe(FDESCRIBE); expect(name).toBe('case1'); + expect(value).toBe('one'); }); it('with test disabled', () => { - const testcases = [{ name: 'case1' }] as const; + const testcases = { + case1: 'one' + } as const; const spy = jasmine.createSpy(); - parameterizeSpec(testcases, spy, { - case1: XIT + parameterize('suite', testcases, spy, { + case1: XDESCRIBE }); expect(spy).toHaveBeenCalledTimes(1); - const { spec, name } = paramertizeListTestArgs( + const { spec, name, value } = parameterizeSuiteTestArgs( spy.calls.argsFor(0) ); - expect(spec).toBe(XIT); + expect(spec).toBe(XDESCRIBE); expect(name).toBe('case1'); + expect(value).toBe('one'); }); it('with various test cases enabled and disabled', () => { - const testcases = [ - { name: 'case1' }, - { name: 'case2' }, - { name: 'case3' } - ] as const; + const testcases = { + case1: 'one', + case2: 'two', + case3: 'three' + } as const; const spy = jasmine.createSpy(); - parameterizeSpec(testcases, spy, { - case2: XIT, - case3: FIT + parameterize('suite', testcases, spy, { + case2: XDESCRIBE, + case3: FDESCRIBE }); expect(spy).toHaveBeenCalledTimes(3); { - const { spec, name } = paramertizeListTestArgs( + const { spec, name, value } = parameterizeSuiteTestArgs( spy.calls.argsFor(0) ); - expect(spec).toBe(IT); + expect(spec).toBe(DESCRIBE); expect(name).toBe('case1'); + expect(value).toBe('one'); } { - const { spec, name } = paramertizeListTestArgs( + const { spec, name, value } = parameterizeSuiteTestArgs( spy.calls.argsFor(1) ); - expect(spec).toBe(XIT); + expect(spec).toBe(XDESCRIBE); expect(name).toBe('case2'); + expect(value).toBe('two'); } { - const { spec, name } = paramertizeListTestArgs( + const { spec, name, value } = parameterizeSuiteTestArgs( spy.calls.argsFor(2) ); - expect(spec).toBe(FIT); + expect(spec).toBe(FDESCRIBE); expect(name).toBe('case3'); + expect(value).toBe('three'); } }); }); describe('errors', () => { it('for override not in test cases', () => { - const testcases = [{ name: 'case1' }] as { name: string }[]; + const testcases = { + case1: 'one' + } as { [key: string]: string }; expect(() => { - parameterizeSpec(testcases, () => {}, { - unknown: XIT + parameterize('suite', testcases, () => {}, { + unknown: XDESCRIBE }); }).toThrowError(/override names must match test case name/); }); it('for override not referencing supported xit or fit', () => { - const testcases = [{ name: 'case1' }] as const; + const testcases = { + case1: 'one' + } as const; expect(() => { - parameterizeSpec(testcases, () => {}, { - case1: IT + parameterize('suite', testcases, () => {}, { + case1: DESCRIBE }); - }).toThrowError(/jasmine spec functions: fit or xit/); + }).toThrowError(/jasmine suite functions: fdescribe or xdescribe/); }); }); }); diff --git a/packages/jasmine-parameterized/src/types.ts b/packages/jasmine-parameterized/src/types.ts new file mode 100644 index 0000000000..4a4224b5a5 --- /dev/null +++ b/packages/jasmine-parameterized/src/types.ts @@ -0,0 +1,33 @@ +// The following aliases are just to reduce the number +// of eslint disables in this source file. In normal +// test code use the globals directly so eslint can +// guard accidental check-ins of fit, etc. +// eslint-disable-next-line no-restricted-globals +export type Fit = typeof fit; +export type Xit = typeof xit; +export type It = typeof it; +/** + * One of the jasmine spec functions: fit, xit, or it + */ +export type Spec = Fit | Xit | It; +/** + * One of the jasmine spec functions: fit or xit + */ +export type SpecOverride = Fit | Xit; + +// eslint-disable-next-line no-restricted-globals +export type Fdescribe = typeof fdescribe; +export type Xdescribe = typeof xdescribe; +export type Describe = typeof describe; +/** + * One of the jasmine spec functions: fit, xit, or it + */ +export type Suite = Fdescribe | Xdescribe | Describe; +/** + * One of the jasmine spec functions: fit or xit + */ +export type SuiteOverride = Fdescribe | Xdescribe; + +export type ObjectFromNamedList = { + [K in T extends readonly { name: infer U }[] ? U : never]: T[number]; +}; diff --git a/packages/nimble-components/src/menu-button/tests/menu-button.spec.ts b/packages/nimble-components/src/menu-button/tests/menu-button.spec.ts index 06acd371dc..ba0b2ee938 100644 --- a/packages/nimble-components/src/menu-button/tests/menu-button.spec.ts +++ b/packages/nimble-components/src/menu-button/tests/menu-button.spec.ts @@ -8,6 +8,7 @@ import { keySpace } from '@microsoft/fast-web-utilities'; import { FoundationElement, Menu, MenuItem } from '@microsoft/fast-foundation'; +import { parameterizeSuite } from '@ni/jasmine-parameterized'; import { fixture, Fixture } from '../../utilities/tests/fixture'; import { MenuButton } from '..'; import { MenuButtonToggleEventDetail, MenuButtonPosition } from '../types'; @@ -319,27 +320,20 @@ describe('MenuButton', () => { }); }); - interface MenuSlotConfiguration { - description: string; - setupFunction: () => Promise>; - getMenuButton: (element: HTMLElement) => MenuButton; - } - - const menuSlotConfigurations: MenuSlotConfiguration[] = [ + const menuSlotConfigurations = [ { - description: 'menu slotted directly in menu-button', + name: 'menu slotted directly in menu-button', setupFunction: setup, getMenuButton: (element: HTMLElement) => element as MenuButton }, { - description: 'menu passed through slot of additional element', + name: 'menu passed through slot of additional element', setupFunction: slottedSetup, getMenuButton: (element: HTMLElement) => element.shadowRoot!.querySelector('nimble-menu-button')! } - ]; - for (const configuration of menuSlotConfigurations) { - // eslint-disable-next-line @typescript-eslint/no-loop-func - describe(`menu interaction with ${configuration.description}`, () => { + ] as const; + parameterizeSuite(menuSlotConfigurations, (suite, name, value) => { + suite(`menu interaction with ${name}`, () => { let element: HTMLElement; let connect: () => Promise; let disconnect: () => Promise; @@ -358,7 +352,7 @@ describe('MenuButton', () => { } beforeEach(async () => { - ({ element, connect, disconnect, parent } = await configuration.setupFunction()); + ({ element, connect, disconnect, parent } = await value.setupFunction()); createAndSlotMenu(element); }); @@ -368,7 +362,7 @@ describe('MenuButton', () => { it('should open the menu and focus first menu item when the toggle button is clicked', async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); const toggleListener = createEventListener( menuButton, 'toggle' @@ -381,7 +375,7 @@ describe('MenuButton', () => { it("should open the menu and focus first menu item when 'Enter' is pressed while the toggle button is focused", async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); const toggleListener = createEventListener( menuButton, 'toggle' @@ -397,7 +391,7 @@ describe('MenuButton', () => { it("should open the menu and focus first menu item when 'Space' is pressed while the toggle button is focused", async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); const toggleListener = createEventListener( menuButton, 'toggle' @@ -413,7 +407,7 @@ describe('MenuButton', () => { it('should open the menu and focus first menu item when the down arrow is pressed while the toggle button is focused', async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); const toggleListener = createEventListener( menuButton, 'toggle' @@ -429,7 +423,7 @@ describe('MenuButton', () => { it('should open the menu and focus last menu item when the up arrow is pressed while the toggle button is focused', async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); const toggleListener = createEventListener( menuButton, 'toggle' @@ -445,7 +439,7 @@ describe('MenuButton', () => { it("should close the menu when pressing 'Escape'", async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); await openMenu(menuButton); const event = new KeyboardEvent('keydown', { @@ -457,7 +451,7 @@ describe('MenuButton', () => { it("should focus the button when the menu is closed by pressing 'Escape'", async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); await openMenu(menuButton); const event = new KeyboardEvent('keydown', { @@ -469,7 +463,7 @@ describe('MenuButton', () => { it('should close the menu when selecting a menu item by clicking it', async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); await openMenu(menuButton); menuItem1.click(); @@ -478,7 +472,7 @@ describe('MenuButton', () => { it('should focus the button when the menu is closed by selecting a menu item by clicking it', async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); await openMenu(menuButton); menuItem1.click(); @@ -487,7 +481,7 @@ describe('MenuButton', () => { it("should close the menu when selecting a menu item using 'Enter'", async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); await openMenu(menuButton); const event = new KeyboardEvent('keydown', { @@ -499,7 +493,7 @@ describe('MenuButton', () => { it("should focus the button when the menu is closed by selecting a menu item using 'Enter'", async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); await openMenu(menuButton); const event = new KeyboardEvent('keydown', { @@ -517,7 +511,7 @@ describe('MenuButton', () => { }; await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); await openMenu(menuButton); menuItem1.addEventListener(eventChange, onMenuItemChange); @@ -528,7 +522,7 @@ describe('MenuButton', () => { it('should not close the menu when clicking on a disabled menu item', async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); await openMenu(menuButton); menuItem1.disabled = true; @@ -540,7 +534,7 @@ describe('MenuButton', () => { const focusableElement = document.createElement('input'); parent.appendChild(focusableElement); await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); // Start with the focus on the menu button so that it can lose focus later menuButton.focus(); menuButton.open = true; @@ -550,11 +544,10 @@ describe('MenuButton', () => { expect(menuButton.open).toBeFalse(); }); }); - } + }); - for (const configuration of menuSlotConfigurations) { - // eslint-disable-next-line @typescript-eslint/no-loop-func - describe(`menu interaction without a ${configuration.description}`, () => { + parameterizeSuite(menuSlotConfigurations, (suite, name, value) => { + suite(`menu interaction without a ${name}`, () => { let element: HTMLElement; let connect: () => Promise; let disconnect: () => Promise; @@ -573,7 +566,7 @@ describe('MenuButton', () => { } beforeEach(async () => { - ({ element, connect, disconnect, parent } = await configuration.setupFunction()); + ({ element, connect, disconnect, parent } = await value.setupFunction()); // Unlike other tests, explicitly do not slot a menu in the parent element }); @@ -583,7 +576,7 @@ describe('MenuButton', () => { it('should transition to the open state when the toggle button is clicked', async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); const toggleListener = createEventListener( menuButton, 'toggle' @@ -603,7 +596,7 @@ describe('MenuButton', () => { it("should transition to the open state when 'Enter' is pressed while the toggle button is focused", async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); const toggleListener = createEventListener( menuButton, 'toggle' @@ -626,7 +619,7 @@ describe('MenuButton', () => { it("should transition to the open state when 'Space' is pressed while the toggle button is focused", async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); const toggleListener = createEventListener( menuButton, 'toggle' @@ -649,7 +642,7 @@ describe('MenuButton', () => { it('should transition to the open state when the down arrow is pressed while the toggle button is focused', async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); const toggleListener = createEventListener( menuButton, 'toggle' @@ -672,7 +665,7 @@ describe('MenuButton', () => { it('should transition to the open state when the up arrow is pressed while the toggle button is focused', async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); const toggleListener = createEventListener( menuButton, 'toggle' @@ -695,7 +688,7 @@ describe('MenuButton', () => { it("should transition to the closed state when pressing 'Escape'", async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); await openMenu(menuButton); const event = new KeyboardEvent('keydown', { @@ -707,7 +700,7 @@ describe('MenuButton', () => { it("should focus the button when moving to the closed state by pressing 'Escape'", async () => { await connect(); - const menuButton = configuration.getMenuButton(element); + const menuButton = value.getMenuButton(element); await openMenu(menuButton); const event = new KeyboardEvent('keydown', { @@ -717,5 +710,5 @@ describe('MenuButton', () => { expect(document.activeElement).toEqual(element); }); }); - } + }); }); diff --git a/packages/nimble-components/src/select/tests/select.spec.ts b/packages/nimble-components/src/select/tests/select.spec.ts index d4cd1fb97c..7f23f76d8f 100644 --- a/packages/nimble-components/src/select/tests/select.spec.ts +++ b/packages/nimble-components/src/select/tests/select.spec.ts @@ -1,5 +1,5 @@ import { html, repeat } from '@microsoft/fast-element'; -import { parameterizeSpec } from '@ni/jasmine-parameterized'; +import { parameterizeSpec, parameterizeSuite } from '@ni/jasmine-parameterized'; import { fixture, Fixture } from '../../utilities/tests/fixture'; import { Select, selectTag } from '..'; import { ListOption, listOptionTag } from '../../list-option'; @@ -531,23 +531,24 @@ describe('Select', () => { filter: FilterMode.standard, name: 'standard' } - ]; - filterModeTestData.forEach(testData => { - describe(`with filterMode = ${testData.name}`, () => { + ] as const; + parameterizeSuite(filterModeTestData, (suite, name, value) => { + suite(`with filterMode = ${name}`, () => { + beforeEach(() => { + element.filterMode = value.filter; + }); + it('pressing opens dropdown', () => { - element.filterMode = testData.filter; pageObject.pressEnterKey(); expect(element.open).toBeTrue(); }); it('pressing opens dropdown', async () => { - element.filterMode = testData.filter; await pageObject.pressSpaceKey(); expect(element.open).toBeTrue(); }); it('after pressing to close dropdown, will re-open dropdown', () => { - element.filterMode = testData.filter; pageObject.clickSelect(); pageObject.pressEscapeKey(); expect(element.open).toBeFalse(); @@ -556,14 +557,12 @@ describe('Select', () => { }); it('after closing dropdown by pressing , activeElement is Select element', () => { - element.filterMode = testData.filter; pageObject.clickSelect(); pageObject.pressEscapeKey(); expect(document.activeElement).toBe(element); }); it('after closing dropdown by committing a value with , activeElement is Select element', () => { - element.filterMode = testData.filter; pageObject.clickSelect(); pageObject.pressArrowDownKey(); pageObject.pressEnterKey(); diff --git a/packages/nimble-components/src/table-column/icon/tests/table-column-icon.spec.ts b/packages/nimble-components/src/table-column/icon/tests/table-column-icon.spec.ts index 299243be3e..244ca49b71 100644 --- a/packages/nimble-components/src/table-column/icon/tests/table-column-icon.spec.ts +++ b/packages/nimble-components/src/table-column/icon/tests/table-column-icon.spec.ts @@ -1,5 +1,5 @@ import { html, repeat, ref } from '@microsoft/fast-element'; -import { parameterizeSpec } from '@ni/jasmine-parameterized'; +import { parameterizeSpec, parameterizeSuite } from '@ni/jasmine-parameterized'; import { Table, tableTag } from '../../../table'; import { TableColumnIcon, tableColumnIconTag } from '..'; import { waitForUpdatesAsync } from '../../../testing/async-helpers'; @@ -635,9 +635,8 @@ describe('TableColumnIcon', () => { } ] as const; - for (const mappingType of mappingTypes) { - // eslint-disable-next-line @typescript-eslint/no-loop-func - describe(`in ${mappingType.name}`, () => { + parameterizeSuite(mappingTypes, (suite, name, value) => { + suite(`in ${name}`, () => { beforeEach(async () => { ({ connect, disconnect, model } = await setup({ keyType: MappingKeyType.string, @@ -652,7 +651,7 @@ describe('TableColumnIcon', () => { columnPageObject = new TableColumnIconPageObject( pageObject ); - await model.table.setData([{ field1: mappingType.type }]); + await model.table.setData([{ field1: value.type }]); await connect(); model.col1.groupIndex = 0; await waitForUpdatesAsync(); @@ -726,7 +725,7 @@ describe('TableColumnIcon', () => { ).toBe('alpha'); }); }); - } + }); }); describe('overflow', () => { @@ -745,9 +744,8 @@ describe('TableColumnIcon', () => { } ] as const; - for (const mappingType of mappingTypes) { - // eslint-disable-next-line @typescript-eslint/no-loop-func - describe(`in ${mappingType.name}`, () => { + parameterizeSuite(mappingTypes, (suite, name, value) => { + suite(`in ${name}`, () => { const longText = 'a very long value that should get ellipsized due to not fitting within the default cell width'; const shortText = 'short value'; const longTextRowIndex = 0; @@ -784,8 +782,8 @@ describe('TableColumnIcon', () => { pageObject ); await model.table.setData([ - { field1: `${mappingType.type}-long` }, - { field1: `${mappingType.type}-short` } + { field1: `${value.type}-long` }, + { field1: `${value.type}-short` } ]); await connect(); model.table.style.width = '200px'; @@ -888,6 +886,6 @@ describe('TableColumnIcon', () => { ).toBe(''); }); }); - } + }); }); });