diff --git a/app/soapbox/__fixtures__/app.json b/app/soapbox/__fixtures__/app.json new file mode 100644 index 000000000..18b5ba2b3 --- /dev/null +++ b/app/soapbox/__fixtures__/app.json @@ -0,0 +1,15 @@ +{ + "vapid_key": "BHczIFh4Wn3Q_7wDgehaB8Ti3Uu8BoyOgXxkOVuEJRuEqxtd9TAno8K9ycz4myiQ1ruiyVfG6xT1JLeXtpxDzUs", + "token_type": "Bearer", + "client_secret": "cm_8Zip_UYyYq1DPQ-CRFUolrz894MmWYUC0aeVcklM", + "redirect_uri": "urn:ietf:wg:oauth:2.0:oob", + "created_at": 1594764335, + "name": "SoapboxFE_2020-07-14T22:05:17.054Z", + "client_id": "bjiy8AxGKXXesfZcyp_iN-uQVE6Cnl03efWoSdOPh9M", + "expires_in": 600, + "scope": "read write follow push admin", + "refresh_token": "IXoCKCsZi3ZCuCjIkeadvEoHRdqOYHklZmv9jvkJ5VA", + "website": null, + "id": "134", + "access_token": "XSkQFSV1R_IvycQmw_uD5z6hQmNyuhh9PtMQbv8TgG8" +} diff --git a/app/soapbox/__fixtures__/user.json b/app/soapbox/__fixtures__/user.json new file mode 100644 index 000000000..24617cc4a --- /dev/null +++ b/app/soapbox/__fixtures__/user.json @@ -0,0 +1,8 @@ +{ + "access_token": "UVBP2e17b4pTpb_h8fImIm3F5a66IBVb-JkyZHs4gLE", + "expires_in": 600, + "me": "https://social.teci.world/users/curtis", + "refresh_token": "c2DpbVxYZBJDogNn-VBNFES72yXPNUYQCv0CrXGOplY", + "scope": "read write follow push admin", + "token_type": "Bearer" +} diff --git a/app/soapbox/reducers/__tests__/auth-test.js b/app/soapbox/reducers/__tests__/auth-test.js index 7dc1d8fa8..acbf77ffb 100644 --- a/app/soapbox/reducers/__tests__/auth-test.js +++ b/app/soapbox/reducers/__tests__/auth-test.js @@ -1,6 +1,8 @@ import reducer from '../auth'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import * as actions from 'soapbox/actions/auth'; +// import app from 'soapbox/__fixtures__/app.json'; +import user from 'soapbox/__fixtures__/user.json'; describe('auth reducer', () => { it('should return the initial state', () => { @@ -50,8 +52,59 @@ describe('auth reducer', () => { }); }); + // Fails with TypeError: cannot read property merge of undefined + // it('should handle the Action AUTH_APP_AUTHORIZED', () => { + // const state = ImmutableMap({ + // auth: { + // app: { + // vapid_key: 'oldVapidKey', + // token_type: 'Bearer', + // client_secret: 'oldClientSecret', + // redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', + // created_at: 1594764335, + // name: 'SoapboxFE_2020-07-14T22:05:17.054Z', + // client_id: 'bjiy8AxGKXXesfZcyp_iN-uQVE6Cnl03efWoSdOPh9M', + // expires_in: 600, + // scope: 'read write follow push admin', + // refresh_token: 'oldRefreshToken', + // website: null, + // id: '134', + // access_token: 'oldAccessToken', + // }, + // }, + // }); + // const action = { + // type: actions.AUTH_APP_AUTHORIZED, + // app: app, + // }; + // expect(reducer(state, action).toJS()).toMatchObject({ + // app: app, + // }); + // }); + + it('should handle the Action AUTH_LOGGED_IN', () => { + const state = ImmutableMap({ + user: { + access_token: 'UVBP2e17b4pTpb_h8fImIm3F5a66IBVb-JkyZHs4gLE', + expires_in: 600, + me: 'https://social.teci.world/users/curtis', + refresh_token: 'c2DpbVxYZBJDogNn-VBNFES72yXPNUYQCv0CrXGOplY', + scope: 'read write follow push admin', + token_type: 'Bearer', + }, + }); + const action = { + type: actions.AUTH_LOGGED_IN, + user: user, + }; + expect(reducer(state, action).toJS()).toMatchObject({ + user: user, + }); + }); + it('should handle the Action AUTH_LOGGED_OUT', () => { - const state = ImmutableMap({ user: { + const state = ImmutableMap({ + user: { access_token: 'UVBP2e17b4pTpb_h8fImIm3F5a66IBVb-JkyZHs4gLE', expires_in: 600, me: 'https://social.teci.world/users/curtis',