File tree Expand file tree Collapse file tree 1 file changed +19
-16
lines changed Expand file tree Collapse file tree 1 file changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -54,27 +54,30 @@ export const LoggedIn: Story = {
5454export const NotLoggedIn : Story = { }
5555
5656export const LoginShouldGetOAuthTokenAndSetCookie : Story = {
57+ parameters : {
58+ msw : {
59+ // Mock out OAUTH
60+ handlers : [
61+ http . post (
62+ 'https://github.com/login/oauth/access_token' ,
63+ async ( { request } ) => {
64+ let json = ( await request . json ( ) ) as any
65+ return Response . json ( { access_token : json . code } )
66+ } ,
67+ ) ,
68+ http . get ( 'https://api.github.com/user' , async ( { request } ) =>
69+ Response . json ( {
70+ login : request . headers . get ( 'Authorization' ) ?. replace ( 'token ' , '' ) ,
71+ } ) ,
72+ ) ,
73+ ] ,
74+ } ,
75+ } ,
5776 beforeEach ( ) {
5877 // Point the login implementation to the endpoint github would have redirected too.
5978 login . mockImplementation ( async ( ) => {
6079 return await auth . GET ( new Request ( '/auth?code=storybookjs' ) )
6180 } )
62-
63- // Mock out OAUTH
64- getWorker ( ) . use (
65- http . post (
66- 'https://github.com/login/oauth/access_token' ,
67- async ( { request } ) => {
68- let json = ( await request . json ( ) ) as any
69- return Response . json ( { access_token : json . code } )
70- } ,
71- ) ,
72- http . get ( 'https://api.github.com/user' , async ( { request } ) =>
73- Response . json ( {
74- login : request . headers . get ( 'Authorization' ) ?. replace ( 'token ' , '' ) ,
75- } ) ,
76- ) ,
77- )
7881 } ,
7982 play : async ( { canvasElement } ) => {
8083 console . log ( db . $getInternalState ( ) )
You can’t perform that action at this time.
0 commit comments