55 * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66 */
77import * as path from 'path' ;
8+ import { strict as assert } from 'node:assert' ;
89import { expect } from 'chai' ;
910import { DescribeSObjectResult } from 'jsforce' ;
1011import { TestSession , execCmd } from '@salesforce/cli-plugins-testkit' ;
12+ import { SObjectListResult } from '../src/commands/sobject/list' ;
1113
1214let session : TestSession ;
1315
@@ -63,32 +65,35 @@ describe('verifies all commands run successfully ', () => {
6365
6466 describe ( 'list command' , ( ) => {
6567 it ( 'requests all objects by default' , ( ) => {
66- const output = execCmd < string [ ] > ( 'force:schema:sobject:list --json' , { ensureExitCode : 0 } ) . jsonOutput ;
67- expect ( output . result ) . to . have . length . greaterThan ( 1 ) ;
68- allObjects = output . result ;
68+ const result = execCmd < SObjectListResult > ( 'force:schema:sobject:list --json' , { ensureExitCode : 0 } ) . jsonOutput
69+ ?. result ;
70+ assert ( result ?. length ) ;
71+ expect ( result ) . to . have . length . greaterThan ( 1 ) ;
72+ allObjects = result ;
6973 } ) ;
7074
7175 it ( 'requests all objects explicity' , ( ) => {
72- const output = execCmd < string [ ] > ( 'force:schema:sobject:list --json --sobjecttypecategory ALL' , {
76+ const result = execCmd < SObjectListResult > ( 'force:schema:sobject:list --json --sobjecttypecategory ALL' , {
7377 ensureExitCode : 0 ,
74- } ) . jsonOutput ;
75- expect ( output . result ) . to . have . length ( allObjects . length ) ;
76- allObjects = output . result ;
78+ } ) . jsonOutput ?. result ;
79+ assert ( result ) ;
80+ expect ( result ) . to . have . length ( allObjects . length ) ;
81+ allObjects = result ;
7782 } ) ;
7883
7984 it ( 'requests standard objects' , ( ) => {
80- const output = execCmd < string [ ] > ( 'force:schema:sobject:list --json --sobjecttypecategory STANDARD' , {
85+ const result = execCmd < SObjectListResult > ( 'force:schema:sobject:list --json --sobjecttypecategory STANDARD' , {
8186 ensureExitCode : 0 ,
82- } ) . jsonOutput ;
87+ } ) . jsonOutput ?. result ;
8388 // all the objects are standard in a vanilla scratch org
84- expect ( output . result ) . to . have . length ( allObjects . length ) ;
89+ expect ( result ) . to . have . length ( allObjects . length ) ;
8590 } ) ;
8691
8792 it ( 'requests custom objects but finds none in vanilla scratch org' , ( ) => {
88- const output = execCmd < string [ ] > ( 'force:schema:sobject:list --json --sobjecttypecategory CUSTOM' , {
93+ const result = execCmd < SObjectListResult > ( 'force:schema:sobject:list --json --sobjecttypecategory CUSTOM' , {
8994 ensureExitCode : 0 ,
90- } ) . jsonOutput ;
91- expect ( output . result ) . to . have . length ( 0 ) ;
95+ } ) . jsonOutput ?. result ;
96+ expect ( result ) . to . have . length ( 0 ) ;
9297 } ) ;
9398
9499 it ( 'no errors on non-json commands' , ( ) => {
@@ -104,14 +109,14 @@ describe('verifies all commands run successfully ', () => {
104109 const output = execCmd < DescribeSObjectResult > ( 'force:schema:sobject:describe --sobjecttype Account --json' , {
105110 ensureExitCode : 0 ,
106111 } ) . jsonOutput ;
107- expect ( output . result ) . to . include . keys ( objectDescribeKeys ) ;
112+ expect ( output ? .result ) . to . include . keys ( objectDescribeKeys ) ;
108113 } ) ;
109114
110115 it ( 'describes ApexClass via toolingApi' , ( ) => {
111116 const output = execCmd < DescribeSObjectResult > ( 'force:schema:sobject:describe --sobjecttype ApexClass -t --json' , {
112117 ensureExitCode : 0 ,
113118 } ) . jsonOutput ;
114- expect ( output . result ) . to . include . keys ( objectDescribeKeys ) ;
119+ expect ( output ? .result ) . to . include . keys ( objectDescribeKeys ) ;
115120 } ) ;
116121
117122 it ( 'no errors on non-json commands' , ( ) => {
0 commit comments