Skip to content

Commit

Permalink
test: assert error and action
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Mar 17, 2023
1 parent ade927c commit 1369791
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/unit/projectTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */

import { join, sep } from 'path';
import { expect } from 'chai';
import { expect, assert } from 'chai';

import { env } from '@salesforce/kit';
import { Messages, NamedPackageDir } from '../../src/exported';
import { Messages, NamedPackageDir, SfError } from '../../src/exported';
import { SfProject, SfProjectJson } from '../../src/sfProject';
import { shouldThrow, shouldThrowSync, TestContext } from '../../src/testSetup';

Expand Down Expand Up @@ -432,6 +432,21 @@ describe('SfProject', () => {
expect(actual).to.deep.equal(expected);
});

it('defaultPackage should error when no package dirs', async () => {
$$.setConfigStubContents('SfProjectJson', {
contents: { packageDirectories: [] },
});
const project = await SfProject.resolve();

try {
shouldThrowSync(() => project.getDefaultPackage());
} catch (e) {
assert(e instanceof SfError);
expect(e.name).to.equal('NoPackageDirectories');
expect(e.actions).to.have.length.greaterThan(0);
}
});

it('should error when one package is defined and set to default=false', async () => {
const expectedPackage1 = 'foo';

Expand Down

0 comments on commit 1369791

Please sign in to comment.