forked from salesforcecli/plugin-deploy-retrieve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.test.ts
78 lines (70 loc) · 2.6 KB
/
start.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { expect } from 'chai';
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup';
import { stubSfCommandUx } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import DeployMetadata from '../../../src/commands/project/deploy/start';
Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'deploy.metadata');
describe('project deploy start', () => {
const $$ = new TestContext();
const testOrg = new MockTestOrgData();
testOrg.isScratchOrg = true;
let warnStub: sinon.SinonStub;
beforeEach(async () => {
await $$.stubAuths(testOrg);
await $$.stubConfig({ 'target-org': testOrg.username });
warnStub = stubSfCommandUx($$.SANDBOX).warn;
});
afterEach(() => {
$$.restore();
});
it('should emit warning when PPDS=true', async () => {
$$.setConfigStubContents('SfProjectJson', {
contents: {
packageDirectories: [{ path: 'force-app', default: true }],
pushPackageDirectoriesSequentially: true,
},
});
try {
await DeployMetadata.run([]);
} catch (e) {
expect(warnStub.getCalls().flatMap((call: { args: string[] }) => call.args)).to.deep.include(
messages.getMessage('pushPackageDirsWarning')
); // do nothing, only need to assert that it warns correctly, avoid too much UT setup
}
});
it('should not emit warning when PPDS=true and flags', async () => {
$$.setConfigStubContents('SfProjectJson', {
contents: {
packageDirectories: [{ path: 'force-app', default: true }],
pushPackageDirectoriesSequentially: true,
},
});
try {
await DeployMetadata.run(['--source-dir', 'test']);
} catch (e) {
expect(warnStub.called).to.be.false;
// do nothing, only need to assert that it warns correctly, avoid too much UT setup
}
});
it('should not emit warning when PPDS=false and a flag', async () => {
$$.setConfigStubContents('SfProjectJson', {
contents: {
packageDirectories: [{ path: 'force-app', default: true }],
pushPackageDirectoriesSequentially: false,
},
});
try {
await DeployMetadata.run(['--source-dir', 'test']);
} catch (e) {
expect(warnStub.called).to.be.false;
// do nothing, only need to assert that it warns correctly, avoid too much UT setup
}
});
});