55 cancelSignIn ,
66 attemptId ,
77 AttemptStateMap ,
8- signInWithModalPrompt ,
9- closeSignInModal ,
108 signInWithoutPrompt ,
119} from './atlas-signin-reducer' ;
1210import { expect } from 'chai' ;
@@ -176,7 +174,7 @@ describe('atlasSignInReducer', function () {
176174 atlasAuthService : mockAtlasService as any ,
177175 } ) ;
178176
179- void store . dispatch ( signInWithModalPrompt ( ) ) . catch ( ( ) => { } ) ;
177+ void store . dispatch ( signInWithoutPrompt ( ) ) . catch ( ( ) => { } ) ;
180178
181179 await Promise . all ( [
182180 store . dispatch ( signIn ( ) ) ,
@@ -186,101 +184,6 @@ describe('atlasSignInReducer', function () {
186184 } ) ;
187185 } ) ;
188186
189- describe ( 'signInWithModalPrompt' , function ( ) {
190- it ( 'should resolve when user finishes sign in with prompt flow' , async function ( ) {
191- const mockAtlasService = {
192- isAuthenticated : sandbox . stub ( ) . resolves ( false ) ,
193- signIn : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
194- getUserInfo : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
195- emit : sandbox . stub ( ) ,
196- } ;
197- const store = configureStore ( {
198- atlasAuthService : mockAtlasService as any ,
199- } ) ;
200-
201- const signInPromise = store . dispatch ( signInWithModalPrompt ( ) ) ;
202- await store . dispatch ( signIn ( ) ) ;
203- await signInPromise ;
204-
205- expect ( store . getState ( ) ) . to . have . property ( 'state' , 'success' ) ;
206- } ) ;
207-
208- it ( 'should reject if sign in flow fails' , async function ( ) {
209- const mockAtlasService = {
210- isAuthenticated : sandbox . stub ( ) . resolves ( false ) ,
211- signIn : sandbox . stub ( ) . rejects ( new Error ( 'Whoops!' ) ) ,
212- getUserInfo : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
213- emit : sandbox . stub ( ) ,
214- } ;
215- const store = configureStore ( {
216- atlasAuthService : mockAtlasService as any ,
217- } ) ;
218-
219- const signInPromise = store . dispatch ( signInWithModalPrompt ( ) ) ;
220- await store . dispatch ( signIn ( ) ) ;
221-
222- try {
223- await signInPromise ;
224- throw new Error ( 'Expected signInPromise to throw' ) ;
225- } catch ( err ) {
226- expect ( err ) . to . have . property ( 'message' , 'Whoops!' ) ;
227- }
228-
229- expect ( store . getState ( ) ) . to . have . property ( 'state' , 'error' ) ;
230- } ) ;
231-
232- it ( 'should reject if user dismissed the modal' , async function ( ) {
233- const mockAtlasService = {
234- isAuthenticated : sandbox . stub ( ) . resolves ( false ) ,
235- signIn : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
236- getUserInfo : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
237- emit : sandbox . stub ( ) ,
238- } ;
239- const store = configureStore ( {
240- atlasAuthService : mockAtlasService as any ,
241- } ) ;
242-
243- const signInPromise = store . dispatch ( signInWithModalPrompt ( ) ) ;
244- store . dispatch ( closeSignInModal ( ) ) ;
245-
246- try {
247- await signInPromise ;
248- throw new Error ( 'Expected signInPromise to throw' ) ;
249- } catch ( err ) {
250- expect ( err ) . to . have . property ( 'message' , 'This operation was aborted' ) ;
251- }
252-
253- expect ( store . getState ( ) ) . to . have . property ( 'state' , 'canceled' ) ;
254- } ) ;
255-
256- it ( 'should reject if provided signal was aborted' , async function ( ) {
257- const mockAtlasService = {
258- isAuthenticated : sandbox . stub ( ) . resolves ( false ) ,
259- signIn : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
260- getUserInfo : sandbox . stub ( ) . resolves ( { sub : '1234' } ) ,
261- emit : sandbox . stub ( ) ,
262- } ;
263- const store = configureStore ( {
264- atlasAuthService : mockAtlasService as any ,
265- } ) ;
266-
267- const c = new AbortController ( ) ;
268- const signInPromise = store . dispatch (
269- signInWithModalPrompt ( { signal : c . signal } )
270- ) ;
271- c . abort ( new Error ( 'Aborted from outside' ) ) ;
272-
273- try {
274- await signInPromise ;
275- throw new Error ( 'Expected signInPromise to throw' ) ;
276- } catch ( err ) {
277- expect ( err ) . to . have . property ( 'message' , 'Aborted from outside' ) ;
278- }
279-
280- expect ( store . getState ( ) ) . to . have . property ( 'state' , 'canceled' ) ;
281- } ) ;
282- } ) ;
283-
284187 describe ( 'signInWithoutPrompt' , function ( ) {
285188 it ( 'should resolve when sign in flow finishes' , async function ( ) {
286189 const mockAtlasService = {
0 commit comments