Skip to content

Commit

Permalink
revert class constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
vid committed Jan 17, 2025
1 parent ae87b73 commit a769467
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions modules/core/src/lib/test/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function getCreateSteppers(steppers: string[], addSteppers?: CStepp
return await createSteppers(csteppers.concat(addSteppers || []));
}

export const testVStep = (name: string, action, base = TEST_BASE): TFeatureStep => ({
export const testFeatureStep = (name: string, action, base = TEST_BASE): TFeatureStep => ({
source: { ...withNameType(base, name, '') },
in: name,
seq: 0,
Expand All @@ -35,7 +35,7 @@ export async function getTestEnv(useSteppers: string[], test: string, world: TWo
const resolver = new Resolver(steppers);
const actions = resolver.findActionableSteps(test);

const featureStep = testVStep('test', actions[0]);
const featureStep = testFeatureStep('test', actions[0]);

return { world, featureStep, csteppers, steppers };
}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/lib/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export async function verifyRequiredOptions(steppers: CStepper[], options: TModu
}

export function getStepperOptionName(stepper: AStepper | CStepper, name: string) {
if ((stepper as CStepper).prototype) {
if ((stepper as CStepper)?.prototype) {
return getPre((stepper as CStepper).prototype) + name;
}
return getPre(stepper as AStepper) + name;
Expand Down
10 changes: 4 additions & 6 deletions modules/core/src/lib/util/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ describe('findHandlers', () => {
TEST_HANDLER
);
expect(found.length).toBe(1);
console.log('name', found[0].stepper);
expect(constructorName(found[0].stepper)).toBe('FallbackTestStepperHandler');
});
});
Expand All @@ -145,22 +144,21 @@ describe('findStepperFromOptions', () => {
};

it('finds from single option', async () => {
const ts = await util.createSteppers([TestOptionsStepper])[0];
const ts = new TestOptionsStepper();
const steppers = await getCreateSteppers([], [TestOptionsStepper]);
const options = { [util.getStepperOptionName(ts, 'A')]: 'TestOptionsStepper' };
const s = util.findStepperFromOption(steppers, ts, options, 'A');
expect(s).toBeDefined();
});
it('finds from last multiple options', async () => {
const ts = util.createSteppers([TestOptionsStepper])[0];
const ts = new TestOptionsStepper();
const steppers = await getCreateSteppers([], [TestOptionsStepper]);
const options = { [util.getStepperOptionName(ts, 'B')]: 'TestOptionsStepper' };
const s = await util.findStepperFromOption(steppers, ts, options, 'A', 'B');
expect(s).toBeDefined();
});
// FIXME vitest where is TestSteps2 coming from?
it('finds from first multiple options', async () => {
const ts = await util.createSteppers([TestOptionsStepper])[0];
const ts = new TestOptionsStepper();
const steppers = await getCreateSteppers([], [TestSteps, TestOptionsStepper]);
const options = {
[util.getStepperOptionName(ts, 'optionA')]: 'TestSteps',
Expand Down Expand Up @@ -200,7 +198,7 @@ describe('verifyRequiredOptions', () => {
};
}
it('has option', async () => {
const toswq = await util.createSteppers([TestOptionsStepperWithReauired])[0];
const toswq = new TestOptionsStepperWithReauired();
const options = { [util.getStepperOptionName(toswq, 'A')]: 'TestSteps' };
await expect(util.verifyRequiredOptions([TestOptionsStepperWithReauired], options)).resolves.not.toThrow();
});
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/phases/Resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ export class Resolver {
} else if (actions.length < 1) {
throw Error(`no step found for ${featureLine.line} in ${feature.path} from ${describeSteppers(this.steppers)}`);
}
const featureStep = this.getVStep(featureLine, seq, actions[0]);
const featureStep = this.getFeatureStep(featureLine, seq, actions[0]);
featureSteps.push(featureStep);
}

return featureSteps;
}

getVStep(featureLine: TExpandedLine, seq: number, action: TStepAction): TFeatureStep {
getFeatureStep(featureLine: TExpandedLine, seq: number, action: TStepAction): TFeatureStep {
return { source: featureLine.feature, in: featureLine.line, seq, action };
}

Expand Down
1 change: 0 additions & 1 deletion modules/storage-mem/src/storage-mem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import StorageMem from './storage-mem.js';
import { Timer } from '@haibun/core/build/lib/Timer.js';
import { EMediaTypes } from '@haibun/domain-storage/build/media-types.js';
import { TRACKS_FILE } from '@haibun/core/build/lib/LogHistory.js';
import { TTree } from '@haibun/domain-storage/build/AStorage.js';

const { key } = Timer;

Expand Down
4 changes: 4 additions & 0 deletions modules/web-playwright/src/BrowserFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ describe("types", () => {
await BrowserFactory.closeBrowsers();
});
it("missing type", async () => {
await expect(async () => await BrowserFactory.getBrowserFactory(new Logger(LOGGER_NOTHING), ({
...browserContextOptions,
type: 'noodles'
} as any) as TBrowserFactoryOptions)).rejects.toThrow();
await expect(async () => await BrowserFactory.getBrowserFactory(new Logger(LOGGER_NOTHING), ({
...browserContextOptions,
type: 'noodles'
Expand Down

0 comments on commit a769467

Please sign in to comment.