@@ -137,27 +137,22 @@ describe('StencilStart unit tests', () => {
137137 const storeHash = 'storeHash_value' ;
138138 const channelId = 5 ;
139139 const storeUrl = 'https://www.example.com' ;
140- it ( 'should obtain channel info object from the api when no channelUrl is provided ' , async ( ) => {
140+ it ( 'should obtain channel id from the api' , async ( ) => {
141141 const channels = [ { channel_id : channelId , url : storeUrl } ] ;
142142 const themeApiClientStub = {
143143 checkCliVersion : jest . fn ( ) ,
144144 getStoreHash : jest . fn ( ) . mockResolvedValue ( storeHash ) ,
145145 getStoreChannels : jest . fn ( ) . mockResolvedValue ( channels ) ,
146146 } ;
147- const stencilPushUtilsStub = {
148- promptUserToSelectChannel : jest . fn ( ) . mockResolvedValue ( channelId ) ,
149- } ;
150147 const { instance } = createStencilStartInstance ( {
151148 themeApiClient : themeApiClientStub ,
152- stencilPushUtils : stencilPushUtilsStub ,
149+ stencilPushUtils : stencilPushUtilsModule ,
153150 } ) ;
154- const stencilConfig = { accessToken, normalStoreUrl : 'https://example.com' , apiHost } ;
155- const cliOptions = { apiHost } ;
156- const result = await instance . getChannelInfo ( stencilConfig , cliOptions ) ;
157- expect ( result ) . toEqual ( channels [ 0 ] ) ;
151+ const result = await instance . getChannelUrl ( { accessToken } , { apiHost } ) ;
152+ expect ( result ) . toEqual ( storeUrl ) ;
158153 } ) ;
159154
160- it ( 'should return the channelUrl string from cliOptions if provided ' , async ( ) => {
155+ it ( 'should obtain channel url from the CLI ' , async ( ) => {
161156 const channelUrl = 'https://shop.bigcommerce.com' ;
162157 const channels = [ { channel_id : channelId , url : storeUrl } ] ;
163158 const themeApiClientStub = {
@@ -169,9 +164,7 @@ describe('StencilStart unit tests', () => {
169164 themeApiClient : themeApiClientStub ,
170165 stencilPushUtils : stencilPushUtilsModule ,
171166 } ) ;
172- const stencilConfig = { accessToken, normalStoreUrl : 'https://example.com' , apiHost } ;
173- const cliOptions = { apiHost, channelUrl } ;
174- const result = await instance . getChannelInfo ( stencilConfig , cliOptions ) ;
167+ const result = await instance . getChannelUrl ( { accessToken } , { apiHost, channelUrl } ) ;
175168 expect ( result ) . toEqual ( channelUrl ) ;
176169 } ) ;
177170 } ) ;
@@ -180,23 +173,9 @@ describe('StencilStart unit tests', () => {
180173 it ( 'should read port from the config file' , async ( ) => {
181174 const port = 1234 ;
182175 const browserSyncStub = getBrowserSyncStub ( ) ;
183- const themeApiClientStub = {
184- checkCliVersion : jest
185- . fn ( )
186- . mockResolvedValue ( { baseUrl : 'example.com' , sslUrl : 'https://example.com' } ) ,
187- getStoreHash : jest . fn ( ) . mockResolvedValue ( 'storeHash_value' ) ,
188- getStoreChannels : jest
189- . fn ( )
190- . mockResolvedValue ( [ { channel_id : 5 , url : 'https://www.example.com' } ] ) ,
191- } ;
192- const stencilPushUtilsStub = {
193- promptUserToSelectChannel : jest . fn ( ) . mockResolvedValue ( 5 ) ,
194- } ;
195176 const { instance } = createStencilStartInstance ( {
196177 browserSync : browserSyncStub ,
197178 stencilConfigManager : getStencilConfigManagerStub ( { port } ) ,
198- themeApiClient : themeApiClientStub ,
199- stencilPushUtils : stencilPushUtilsStub ,
200179 } ) ;
201180 instance . startLocalServer = jest . fn ( ) ;
202181 instance . getStartUpInfo = jest . fn ( ) . mockReturnValue ( 'Start up info' ) ;
@@ -212,23 +191,9 @@ describe('StencilStart unit tests', () => {
212191 it ( 'should read port from the cli' , async ( ) => {
213192 const port = 1234 ;
214193 const browserSyncStub = getBrowserSyncStub ( ) ;
215- const themeApiClientStub = {
216- checkCliVersion : jest
217- . fn ( )
218- . mockResolvedValue ( { baseUrl : 'example.com' , sslUrl : 'https://example.com' } ) ,
219- getStoreHash : jest . fn ( ) . mockResolvedValue ( 'storeHash_value' ) ,
220- getStoreChannels : jest
221- . fn ( )
222- . mockResolvedValue ( [ { channel_id : 5 , url : 'https://www.example.com' } ] ) ,
223- } ;
224- const stencilPushUtilsStub = {
225- promptUserToSelectChannel : jest . fn ( ) . mockResolvedValue ( 5 ) ,
226- } ;
227194 const { instance } = createStencilStartInstance ( {
228195 browserSync : browserSyncStub ,
229196 stencilConfigManager : getStencilConfigManagerStub ( { port : 5678 } ) ,
230- themeApiClient : themeApiClientStub ,
231- stencilPushUtils : stencilPushUtilsStub ,
232197 } ) ;
233198 instance . startLocalServer = jest . fn ( ) ;
234199 instance . getStartUpInfo = jest . fn ( ) . mockReturnValue ( 'Start up info' ) ;
0 commit comments