Skip to content

Commit

Permalink
patch(vest): reverse args without mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Sep 20, 2024
1 parent e341c7b commit 30bdd11
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions packages/vest/src/suite/__tests__/staticSuite.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SuiteSerializer } from 'SuiteSerializer';
import { VestIsolateType } from 'VestIsolateType';
import { describe, it, expect } from 'vitest';
import wait from 'wait';

import { SuiteSerializer } from 'SuiteSerializer';
import { VestIsolateType } from 'VestIsolateType';
import * as vest from 'vest';
import { staticSuite } from 'vest';

Expand Down Expand Up @@ -172,4 +172,15 @@ describe('runStatic', () => {
expect(result.dump()).toHaveProperty('$type', VestIsolateType.Suite);
});
});
describe('When creating the suite with a name', () => {
it("Should set the suite's name", () => {
const suite = vest.create('user_form', () => {
vest.test('t1', () => false);
});

const res = suite.runStatic();

expect(res.suiteName).toBe('user_form');
});
});
});
4 changes: 2 additions & 2 deletions packages/vest/src/suite/createSuite.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assign, CB } from 'vest-utils';
import { asArray, assign, CB } from 'vest-utils';
import { Bus, VestRuntime } from 'vestjs-runtime';

import { TTypedMethods, getTypedMethods } from './getTypedMethods';
Expand Down Expand Up @@ -40,7 +40,7 @@ function createSuite<
>(
...args: [suiteName: SuiteName, suiteCallback: T] | [suiteCallback: T]
): Suite<F, G, T> {
const [suiteCallback, suiteName] = args.reverse() as [T, SuiteName];
const [suiteCallback, suiteName] = asArray(args).reverse() as [T, SuiteName];

validateSuiteCallback(suiteCallback);

Expand Down

0 comments on commit 30bdd11

Please sign in to comment.