-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@W-14442225 - Checks for a list of sobjects and the corresponding cre…
…ate/edit/view qa directories. May require some tweaking during integration, but this should be a good stepping stone.
- Loading branch information
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/test/suite/commands/wizard/lwcGenerationCommand.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
import * as assert from 'assert'; | ||
import * as sinon from 'sinon'; | ||
import * as fs from 'fs'; | ||
import { afterEach, beforeEach } from 'mocha'; | ||
import { LwcGenerationCommand, QuickActionFlags } from '../../../../commands/wizard/lwcGenerationCommand'; | ||
|
||
|
||
export interface DoSomething { | ||
[name: string]: { | ||
view: boolean; | ||
}; | ||
} | ||
|
||
suite('LWC Generation Command Test Suite', () => { | ||
beforeEach(function () { | ||
}); | ||
|
||
afterEach(function () { | ||
sinon.restore(); | ||
}); | ||
|
||
test('Quick Action directories check', async () => { | ||
const baseDir = "force-app/main/default/quickActions"; | ||
const statSyncStub = sinon.stub(fs, 'statSync'); | ||
const statsStub = sinon.createStubInstance(fs.Stats); | ||
statsStub.isDirectory.returns(true); | ||
|
||
// stub the file system responses - any return value is a positive hit, an exception is a negative hit | ||
statSyncStub.withArgs(`${baseDir}/sobject1.view.quickAction-meta.xml`).returns(statsStub); | ||
statSyncStub.withArgs(`${baseDir}/sobject1.edit.quickAction-meta.xml`).returns(statsStub); | ||
statSyncStub.withArgs(`${baseDir}/sobject1.create.quickAction-meta.xml`).returns(statsStub); | ||
|
||
statSyncStub.withArgs(`${baseDir}/sobject2.view.quickAction-meta.xml`).throws("error"); | ||
statSyncStub.withArgs(`${baseDir}/sobject2.edit.quickAction-meta.xml`).throws("error"); | ||
statSyncStub.withArgs(`${baseDir}/sobject2.create.quickAction-meta.xml`).throws("error"); | ||
|
||
const result = LwcGenerationCommand.checkForExistingQuickActions(["sobject1", "sobject2"]); | ||
|
||
assert.equal(result["sobject1"].view, true, "sobject1.view should exist"); | ||
assert.equal(result["sobject1"].edit, true, "sobject1.edit should exist"); | ||
assert.equal(result["sobject1"].create, true, "sobject1.create should exist"); | ||
|
||
assert.equal(result["sobject2"].view, false, "sobject2.view should NOT exist"); | ||
assert.equal(result["sobject2"].edit, false, "sobject2.edit should NOT exist"); | ||
assert.equal(result["sobject2"].create, false, "sobject2.create should NOT exist"); | ||
|
||
}); | ||
}); |