Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Prevent loading overlay from showing when using Sign In With Apple (#…
…1779) * Suppressed Lock overlay for Sign In With Apple connnection * Added tests for container and core/actions
- Loading branch information
Showing
with
266 additions
and 30 deletions.
- +28 −0 src/__tests__/quick-auth/__snapshots__/actions.test.js.snap
- +116 −0 src/__tests__/quick-auth/actions.test.js
- +46 −0 src/__tests__/ui/box/__snapshots__/container.test.jsx.snap
- +53 −25 src/__tests__/ui/box/container.test.jsx
- +2 −1 src/core.js
- +0 −1 src/core/actions.js
- +8 −0 src/core/index.js
- +8 −0 src/quick-auth/actions.js
- +5 −3 src/ui/box/container.jsx
| @@ -0,0 +1,28 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`quick-auth.actions calls logIn with the correct parameters 1`] = ` | ||
| Array [ | ||
| "id", | ||
| Array [], | ||
| Object { | ||
| "connection": "name", | ||
| "connection_scope": undefined, | ||
| "isSubmitting": false, | ||
| "login_hint": "hint", | ||
| "prompt": "prompt", | ||
| }, | ||
| ] | ||
| `; | ||
|
|
||
| exports[`quick-auth.actions sets display to "popup" when using facebook and there's no redirect 1`] = ` | ||
| Array [ | ||
| "id", | ||
| Array [], | ||
| Object { | ||
| "connection": "name", | ||
| "connection_scope": undefined, | ||
| "display": "popup", | ||
| "isSubmitting": false, | ||
| }, | ||
| ] | ||
| `; |
| @@ -0,0 +1,116 @@ | ||
| import { logIn } from '../../quick-auth/actions'; | ||
|
|
||
| jest.mock('../../core/actions', () => ({ | ||
| logIn: jest.fn() | ||
| })); | ||
|
|
||
| jest.mock('store/index', () => ({ | ||
| read: jest.fn(() => 'model'), | ||
| getEntity: 'getEntity', | ||
| swap: jest.fn(), | ||
| updateEntity: 'updateEntity' | ||
| })); | ||
|
|
||
| jest.mock('../../core/index', () => ({ | ||
| id: () => 'id', | ||
| auth: { | ||
| connectionScopes: jest.fn(() => ({ | ||
| get: jest.fn() | ||
| })), | ||
| redirect: jest.fn(() => true) | ||
| }, | ||
| setSuppressSubmitOverlay: jest.fn() | ||
| })); | ||
|
|
||
| describe('quick-auth.actions', () => { | ||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('calls logIn with the correct parameters', () => { | ||
| const connection = { | ||
| get: jest.fn(key => { | ||
| switch (key) { | ||
| case 'name': | ||
| return 'name'; | ||
| case 'strategy': | ||
| return 'google'; | ||
| } | ||
| }) | ||
| }; | ||
|
|
||
| logIn('id', connection, 'hint', 'prompt'); | ||
|
|
||
| const coreActions = require('../../core/actions'); | ||
|
|
||
| expect(coreActions.logIn.mock.calls.length).toBe(1); | ||
| expect(coreActions.logIn.mock.calls[0]).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('sets display to "popup" when using facebook and there\'s no redirect', () => { | ||
| const connection = { | ||
| get: jest.fn(key => { | ||
| switch (key) { | ||
| case 'name': | ||
| return 'name'; | ||
| case 'strategy': | ||
| return 'facebook'; | ||
| } | ||
| }) | ||
| }; | ||
|
|
||
| const core = require('../../core/index'); | ||
| core.auth.redirect = jest.fn(() => false); | ||
|
|
||
| logIn('id', connection); | ||
|
|
||
| const coreActions = require('../../core/actions'); | ||
|
|
||
| expect(coreActions.logIn.mock.calls.length).toBe(1); | ||
| expect(coreActions.logIn.mock.calls[0]).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('calls setSuppressSubmitOverlay with true when using Apple connection', () => { | ||
| const connection = { | ||
| get: jest.fn(key => { | ||
| switch (key) { | ||
| case 'name': | ||
| return 'name'; | ||
| case 'strategy': | ||
| return 'apple'; | ||
| } | ||
| }) | ||
| }; | ||
|
|
||
| logIn('id', connection); | ||
|
|
||
| const { swap } = require('store/index'); | ||
| const l = require('../../core/index'); | ||
|
|
||
| expect(swap.mock.calls.length).toBe(1); | ||
| expect(swap.mock.calls[0][3]).toBe(l.setSupressSubmitOverlay); | ||
| expect(swap.mock.calls[0][4]).toBe(true); | ||
| }); | ||
|
|
||
| it('calls setSuppressSubmitOverlay with false when not using Apple connection', () => { | ||
| const connection = { | ||
| get: jest.fn(key => { | ||
| switch (key) { | ||
| case 'name': | ||
| return 'name'; | ||
| case 'strategy': | ||
| return 'facebook'; | ||
| } | ||
| }) | ||
| }; | ||
|
|
||
| logIn('id', connection); | ||
|
|
||
| const { swap } = require('store/index'); | ||
| const l = require('../../core/index'); | ||
|
|
||
| expect(swap.mock.calls.length).toBe(1); | ||
| expect(swap.mock.calls[0][3]).toBe(l.setSupressSubmitOverlay); | ||
| expect(swap.mock.calls[0][4]).toBe(false); | ||
| }); | ||
| }); |