diff options
Diffstat (limited to 'src/state/session/__tests__/session-test.ts')
-rw-r--r-- | src/state/session/__tests__/session-test.ts | 171 |
1 files changed, 0 insertions, 171 deletions
diff --git a/src/state/session/__tests__/session-test.ts b/src/state/session/__tests__/session-test.ts index b1886ff84..403785858 100644 --- a/src/state/session/__tests__/session-test.ts +++ b/src/state/session/__tests__/session-test.ts @@ -1302,177 +1302,6 @@ describe('session', () => { `) }) - it('updates current account', () => { - let state = getInitialState([]) - - const agent1 = new BskyAgent({service: 'https://alice.com'}) - agent1.session = { - did: 'alice-did', - handle: 'alice.test', - accessJwt: 'alice-access-jwt-1', - refreshJwt: 'alice-refresh-jwt-1', - } - state = run(state, [ - { - type: 'switched-to-account', - newAgent: agent1, - newAccount: agentToSessionAccountOrThrow(agent1), - }, - ]) - expect(state.accounts.length).toBe(1) - expect(state.accounts[0].accessJwt).toBe('alice-access-jwt-1') - expect(state.currentAgentState.did).toBe('alice-did') - - state = run(state, [ - { - type: 'updated-current-account', - updatedFields: { - email: 'alice@foo.bar', - emailConfirmed: false, - }, - }, - ]) - expect(state.accounts.length).toBe(1) - expect(state.accounts[0].email).toBe('alice@foo.bar') - expect(state.accounts[0].emailConfirmed).toBe(false) - expect(state.currentAgentState.did).toBe('alice-did') - expect(printState(state)).toMatchInlineSnapshot(` - { - "accounts": [ - { - "accessJwt": "alice-access-jwt-1", - "deactivated": false, - "did": "alice-did", - "email": "alice@foo.bar", - "emailAuthFactor": false, - "emailConfirmed": false, - "handle": "alice.test", - "pdsUrl": undefined, - "refreshJwt": "alice-refresh-jwt-1", - "service": "https://alice.com/", - }, - ], - "currentAgentState": { - "agent": { - "service": "https://alice.com/", - }, - "did": "alice-did", - }, - "needsPersist": true, - } - `) - - state = run(state, [ - { - type: 'updated-current-account', - updatedFields: { - handle: 'alice-updated.test', - }, - }, - ]) - expect(state.accounts.length).toBe(1) - expect(state.accounts[0].handle).toBe('alice-updated.test') - expect(state.currentAgentState.did).toBe('alice-did') - expect(printState(state)).toMatchInlineSnapshot(` - { - "accounts": [ - { - "accessJwt": "alice-access-jwt-1", - "deactivated": false, - "did": "alice-did", - "email": "alice@foo.bar", - "emailAuthFactor": false, - "emailConfirmed": false, - "handle": "alice-updated.test", - "pdsUrl": undefined, - "refreshJwt": "alice-refresh-jwt-1", - "service": "https://alice.com/", - }, - ], - "currentAgentState": { - "agent": { - "service": "https://alice.com/", - }, - "did": "alice-did", - }, - "needsPersist": true, - } - `) - - const agent2 = new BskyAgent({service: 'https://bob.com'}) - agent2.session = { - did: 'bob-did', - handle: 'bob.test', - accessJwt: 'bob-access-jwt-1', - refreshJwt: 'bob-refresh-jwt-1', - } - state = run(state, [ - { - // Switch to Bob. - type: 'switched-to-account', - newAgent: agent2, - newAccount: agentToSessionAccountOrThrow(agent2), - }, - { - // Update Bob. - type: 'updated-current-account', - updatedFields: { - handle: 'bob-updated.test', - }, - }, - { - // Switch back to Alice. - type: 'switched-to-account', - newAgent: agent1, - newAccount: agentToSessionAccountOrThrow(agent1), - }, - { - // Update Alice. - type: 'updated-current-account', - updatedFields: { - handle: 'alice-updated-2.test', - }, - }, - ]) - expect(printState(state)).toMatchInlineSnapshot(` - { - "accounts": [ - { - "accessJwt": "alice-access-jwt-1", - "deactivated": false, - "did": "alice-did", - "email": undefined, - "emailAuthFactor": false, - "emailConfirmed": false, - "handle": "alice-updated-2.test", - "pdsUrl": undefined, - "refreshJwt": "alice-refresh-jwt-1", - "service": "https://alice.com/", - }, - { - "accessJwt": "bob-access-jwt-1", - "deactivated": false, - "did": "bob-did", - "email": undefined, - "emailAuthFactor": false, - "emailConfirmed": false, - "handle": "bob-updated.test", - "pdsUrl": undefined, - "refreshJwt": "bob-refresh-jwt-1", - "service": "https://bob.com/", - }, - ], - "currentAgentState": { - "agent": { - "service": "https://alice.com/", - }, - "did": "alice-did", - }, - "needsPersist": true, - } - `) - }) - it('replaces local accounts with synced accounts', () => { let state = getInitialState([]) |