Skip to content

Commit

Permalink
fix: session.project knows from Options whether (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc authored Jan 4, 2023
1 parent 075fbf8 commit 8cc92d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/testSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ export interface TestSessionOptions {
* TESTKIT_HUB_INSTANCE = instance url for the hub. Defaults to https://login.salesforce.com
* TESTKIT_AUTH_URL = auth url to be used with auth:sfdxurl:store
*/
export class TestSession extends AsyncOptionalCreatable<TestSessionOptions> {
export class TestSession<T extends TestSessionOptions = TestSessionOptions> extends AsyncOptionalCreatable<T> {
public id: string;
public createdDate: Date;
public dir: string;
public homeDir: string;
public project?: TestProject;
public project!: T['project'] extends TestSessionOptions['project'] ? TestProject : TestProject | undefined;

// this is stored on the class so that tests can set it to something much lower than default
public rmRetryConfig: Partial<RetryConfig<void>> = { retries: 12, delay: 5000 };
Expand All @@ -115,15 +115,15 @@ export class TestSession extends AsyncOptionalCreatable<TestSessionOptions> {
private sandbox = createSandbox();
private retries: number;
private zipDir: typeof zipDir;
private options: TestSessionOptions;
private options: T;
private shelljsExecOptions: shell.ExecOptions = {
silent: true,
};
private orgsAliases: string[] = ['default'];

public constructor(options: TestSessionOptions = {}) {
super(options);
this.options = options;
public constructor(options: T = {} as T) {
super(options ?? ({} as T));
this.options = options ?? ({} as T);
this.debug = debug('testkit:session');
this.zipDir = zipDir;

Expand Down
1 change: 1 addition & 0 deletions test/unit/testSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ describe('TestSession', () => {
session = await TestSession.create();
stubMethod(sandbox, session, 'sleep').resolves();
// @ts-ignore session.sandbox is private
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
restoreSpy = spyMethod(sandbox, session.sandbox, 'restore');
});

Expand Down

0 comments on commit 8cc92d1

Please sign in to comment.