@@ -7,14 +7,12 @@ import { LocationProvider } from '@reach/router';
77import ConfirmSignupCode from '.' ;
88import {
99 IntegrationType ,
10- OAuthIntegrationData ,
1110 OAuthNativeClients ,
1211 OAuthNativeIntegration ,
1312 OAuthNativeServices ,
1413 OAuthWebIntegration ,
1514 RelierClientInfo ,
1615 WebIntegration ,
17- WebIntegrationData ,
1816} from '../../../models' ;
1917import {
2018 MOCK_CLIENT_ID ,
@@ -47,7 +45,9 @@ export const MOCK_SIGNUP_CODE = '123456';
4745
4846export function createMockWebIntegration ( {
4947 redirectTo = undefined ,
50- } : { redirectTo ?: string } = { } ) : ConfirmSignupCodeBaseIntegration {
48+ } : {
49+ redirectTo ?: string ;
50+ } = { } ) : ConfirmSignupCodeBaseIntegration {
5151 // Leaving for historical record. Remove once baked.
5252 // return {
5353 // type: IntegrationType.Web,
@@ -72,10 +72,13 @@ export function createMockWebIntegration({
7272 } )
7373 ) ;
7474
75- expect ( integration . type ) . toEqual ( IntegrationType . Web ) ;
76- expect ( integration . getService ( ) ) . toEqual ( MozServices . Default ) ;
77- expect ( integration . getClientId ( ) ) . toBeUndefined ( ) ;
78- expect ( integration . isDesktopRelay ( ) ) . toBeFalsy ( ) ;
75+ // only run assertions in tests - avoids issues with mocks shared with storybook
76+ if ( typeof expect !== 'undefined' ) {
77+ expect ( integration . type ) . toEqual ( IntegrationType . Web ) ;
78+ expect ( integration . getService ( ) ) . toEqual ( MozServices . Default ) ;
79+ expect ( integration . getClientId ( ) ) . toBeUndefined ( ) ;
80+ expect ( integration . isDesktopRelay ( ) ) . toBeFalsy ( ) ;
81+ }
7982
8083 return integration ;
8184}
@@ -118,14 +121,16 @@ export function createMockOAuthWebIntegration(
118121 redirectUri : MOCK_REDIRECT_URI ,
119122 } as RelierClientInfo ;
120123
121- expect ( integration . type ) . toEqual ( IntegrationType . OAuthWeb ) ;
122- expect ( integration . getRedirectUri ( ) ) . toEqual ( MOCK_REDIRECT_URI ) ;
123- expect ( integration . getService ( ) ) . toEqual ( serviceName ) ;
124- expect ( integration . getClientId ( ) ) . toEqual ( MOCK_CLIENT_ID ) ;
125- expect ( integration . wantsTwoStepAuthentication ( ) ) . toEqual ( false ) ;
126- expect ( integration . isSync ( ) ) . toEqual ( false ) ;
127- expect ( integration . getPermissions ( ) ) . toEqual ( [ 'profile:email' ] ) ;
128- expect ( integration . isDesktopRelay ( ) ) . toEqual ( false ) ;
124+ if ( typeof expect !== 'undefined' ) {
125+ expect ( integration . type ) . toEqual ( IntegrationType . OAuthWeb ) ;
126+ expect ( integration . getRedirectUri ( ) ) . toEqual ( MOCK_REDIRECT_URI ) ;
127+ expect ( integration . getService ( ) ) . toEqual ( serviceName ) ;
128+ expect ( integration . getClientId ( ) ) . toEqual ( MOCK_CLIENT_ID ) ;
129+ expect ( integration . wantsTwoStepAuthentication ( ) ) . toEqual ( false ) ;
130+ expect ( integration . isSync ( ) ) . toEqual ( false ) ;
131+ expect ( integration . getPermissions ( ) ) . toEqual ( [ 'profile:email' ] ) ;
132+ expect ( integration . isDesktopRelay ( ) ) . toEqual ( false ) ;
133+ }
129134
130135 return integration ;
131136}
@@ -177,16 +182,18 @@ export function createMockOAuthNativeIntegration(
177182 } as RelierClientInfo ;
178183 }
179184
180- expect ( integration . type ) . toEqual ( IntegrationType . OAuthNative ) ;
181- expect ( integration . getRedirectUri ( ) ) . toEqual ( MOCK_REDIRECT_URI ) ;
182- expect ( integration . getService ( ) ) . toEqual (
183- isSync ? OAuthNativeServices . Sync : OAuthNativeServices . Relay
184- ) ;
185- expect ( integration . getClientId ( ) ) . toEqual ( MOCK_CLIENT_ID ) ;
186- expect ( integration . wantsTwoStepAuthentication ( ) ) . toEqual ( false ) ;
187- expect ( integration . isSync ( ) ) . toEqual ( isSync ) ;
188- expect ( integration . getPermissions ( ) ) . toEqual ( [ 'profile:email' ] ) ;
189- expect ( integration . isDesktopRelay ( ) ) . toEqual ( ! isSync ) ;
185+ if ( typeof expect !== 'undefined' ) {
186+ expect ( integration . type ) . toEqual ( IntegrationType . OAuthNative ) ;
187+ expect ( integration . getRedirectUri ( ) ) . toEqual ( MOCK_REDIRECT_URI ) ;
188+ expect ( integration . getService ( ) ) . toEqual (
189+ isSync ? OAuthNativeServices . Sync : OAuthNativeServices . Relay
190+ ) ;
191+ expect ( integration . getClientId ( ) ) . toEqual ( MOCK_CLIENT_ID ) ;
192+ expect ( integration . wantsTwoStepAuthentication ( ) ) . toEqual ( false ) ;
193+ expect ( integration . isSync ( ) ) . toEqual ( isSync ) ;
194+ expect ( integration . getPermissions ( ) ) . toEqual ( [ 'profile:email' ] ) ;
195+ expect ( integration . isDesktopRelay ( ) ) . toEqual ( ! isSync ) ;
196+ }
190197
191198 return integration ;
192199}
0 commit comments