Skip to content

Commit eeacd1b

Browse files
Merge pull request #142 from salesforcecli/wr/test
test: add UTs
2 parents 567bf1c + 3eef741 commit eeacd1b

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

test/commands/apex/run/test.test.ts

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,100 @@ describe('apex:test:run', () => {
224224
expect(logStub.firstCall.args[0]).to.include('MyApexTests.testConfig Pass 53');
225225
});
226226

227+
it('should parse tests flags correctly comma separated', async () => {
228+
const apexStub = sandbox.stub(TestService.prototype, 'runTestAsynchronous').resolves(testRunSimple);
229+
230+
await new Test(['--tests', 'MyApexTests,MySecondTest', '--result-format', 'human'], config).run();
231+
expect(apexStub.firstCall.args[0]).to.deep.equal({
232+
skipCodeCoverage: true,
233+
testLevel: 'RunSpecifiedTests',
234+
tests: [
235+
{
236+
className: 'MyApexTests',
237+
},
238+
{
239+
className: 'MySecondTest',
240+
},
241+
],
242+
});
243+
});
244+
245+
it('should parse tests flags correctly multi-flag', async () => {
246+
const apexStub = sandbox.stub(TestService.prototype, 'runTestAsynchronous').resolves(testRunSimple);
247+
248+
await new Test(['--tests', 'MyApexTests', '--tests', 'MySecondTest', '--result-format', 'human'], config).run();
249+
expect(apexStub.firstCall.args[0]).to.deep.equal({
250+
skipCodeCoverage: true,
251+
testLevel: 'RunSpecifiedTests',
252+
tests: [
253+
{
254+
className: 'MyApexTests',
255+
},
256+
{
257+
className: 'MySecondTest',
258+
},
259+
],
260+
});
261+
});
262+
263+
it('should parse class-names flags correctly comma separated', async () => {
264+
const apexStub = sandbox.stub(TestService.prototype, 'runTestAsynchronous').resolves(testRunSimple);
265+
266+
await new Test(['--class-names', 'MyApexTests,MySecondTest', '--result-format', 'human'], config).run();
267+
expect(apexStub.firstCall.args[0]).to.deep.equal({
268+
skipCodeCoverage: true,
269+
testLevel: 'RunSpecifiedTests',
270+
tests: [
271+
{
272+
className: 'MyApexTests',
273+
},
274+
{
275+
className: 'MySecondTest',
276+
},
277+
],
278+
});
279+
});
280+
281+
it('should parse class-names (-n) flags correctly multi-flag', async () => {
282+
const apexStub = sandbox.stub(TestService.prototype, 'runTestAsynchronous').resolves(testRunSimple);
283+
284+
await new Test(['-n', 'MyApexTests', '-n', 'MySecondTest', '--result-format', 'human'], config).run();
285+
expect(apexStub.firstCall.args[0]).to.deep.equal({
286+
skipCodeCoverage: true,
287+
testLevel: 'RunSpecifiedTests',
288+
tests: [
289+
{
290+
className: 'MyApexTests',
291+
},
292+
{
293+
className: 'MySecondTest',
294+
},
295+
],
296+
});
297+
});
298+
299+
it('should parse suite-names flags correctly comma separated', async () => {
300+
const apexStub = sandbox.stub(TestService.prototype, 'runTestAsynchronous').resolves(testRunSimple);
301+
302+
await new Test(['--suite-names', 'MyApexTests,MySecondTest', '--result-format', 'human'], config).run();
303+
expect(apexStub.firstCall.args[0]).to.deep.equal({
304+
skipCodeCoverage: true,
305+
testLevel: 'RunSpecifiedTests',
306+
suiteNames: 'MyApexTests,MySecondTest',
307+
});
308+
});
309+
310+
it('should parse suite-names (-s) flags correctly multi-flag', async () => {
311+
const apexStub = sandbox.stub(TestService.prototype, 'runTestAsynchronous').resolves(testRunSimple);
312+
313+
await new Test(['-s', 'MyApexTests', '-s', 'MySecondTest', '--result-format', 'human'], config).run();
314+
expect(apexStub.firstCall.args[0]).to.deep.equal({
315+
skipCodeCoverage: true,
316+
testLevel: 'RunSpecifiedTests',
317+
suiteNames: 'MyApexTests,MySecondTest',
318+
});
319+
});
320+
227321
it('should return a success tap format message with async', async () => {
228322
sandbox.stub(TestService.prototype, 'runTestAsynchronous').resolves(testRunSimple);
229323

0 commit comments

Comments
 (0)