Skip to content

Commit

Permalink
feat(jest): 83% coverage for store/friends/mutations (#2641)
Browse files Browse the repository at this point in the history
  • Loading branch information
drepram authored Mar 30, 2022
1 parent f0de4f0 commit 4924ddb
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 1 deletion.
145 changes: 145 additions & 0 deletions store/friends/__snapshots__/mutations.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`mutate friends set store false 1`] = `
Array [
Object {
"account": Object {
"accountId": "Checking Account",
"from": ".",
"fromMailboxId": "12345",
"status": 429,
"to": "./path/to/file",
"toMailboxId": "v4.0.0-rc.4",
},
"activeChat": true,
"address": "0xdf9eb223bafbe5c5271415c75aecd68c21fe3d7f",
"badge": "community",
"encryptedTextilePubkey": "",
"item": Object {},
"mailboxId": "",
"name": "Taurus Nix",
"pending": true,
"profilePicture": "",
"publicKey": "NoWiFi4you",
"state": "idle",
"status": "",
"stored": undefined,
"textilePubkey": "https://accounts.google.com/o/oauth2/revoke?token=%s",
"typingState": "NOT_TYPING",
"unreadCount": 123,
"userAccount": "",
},
Object {
"account": Object {
"accountId": "Checking Account",
"from": ".",
"fromMailboxId": "12345",
"status": 429,
"to": "./path/to/file",
"toMailboxId": "v4.0.0-rc.4",
},
"activeChat": true,
"address": "0x1",
"name": "Yusuf Mangunwijaya",
"stored": false,
"textilePubkey": "https://accounts.google.com/o/oauth2/revoke?token=429",
"typingState": "NOT_TYPING",
},
]
`;

exports[`mutate friends set store true 1`] = `
Array [
Object {
"account": Object {
"accountId": "Checking Account",
"from": ".",
"fromMailboxId": "12345",
"status": 429,
"to": "./path/to/file",
"toMailboxId": "v4.0.0-rc.4",
},
"activeChat": true,
"address": "0xdf9eb223bafbe5c5271415c75aecd68c21fe3d7f",
"badge": "community",
"encryptedTextilePubkey": "",
"item": Object {},
"mailboxId": "",
"name": "Taurus Nix",
"pending": true,
"profilePicture": "",
"publicKey": "NoWiFi4you",
"state": "idle",
"status": "",
"stored": undefined,
"textilePubkey": "https://accounts.google.com/o/oauth2/revoke?token=%s",
"typingState": "NOT_TYPING",
"unreadCount": 123,
"userAccount": "",
},
Object {
"account": Object {
"accountId": "Checking Account",
"from": ".",
"fromMailboxId": "12345",
"status": 429,
"to": "./path/to/file",
"toMailboxId": "v4.0.0-rc.4",
},
"activeChat": true,
"address": "0x1",
"name": "Yusuf Mangunwijaya",
"stored": true,
"textilePubkey": "https://accounts.google.com/o/oauth2/revoke?token=429",
"typingState": "NOT_TYPING",
},
]
`;

exports[`mutate friends set typing state 1`] = `
Array [
Object {
"account": Object {
"accountId": "Checking Account",
"from": ".",
"fromMailboxId": "12345",
"status": 429,
"to": "./path/to/file",
"toMailboxId": "v4.0.0-rc.4",
},
"activeChat": true,
"address": "0xdf9eb223bafbe5c5271415c75aecd68c21fe3d7f",
"badge": "community",
"encryptedTextilePubkey": "",
"item": Object {},
"mailboxId": "",
"name": "Taurus Nix",
"pending": true,
"profilePicture": "",
"publicKey": "NoWiFi4you",
"state": "idle",
"status": "",
"stored": undefined,
"textilePubkey": "https://accounts.google.com/o/oauth2/revoke?token=%s",
"typingState": "NOT_TYPING",
"unreadCount": 123,
"userAccount": "",
},
Object {
"account": Object {
"accountId": "Checking Account",
"from": ".",
"fromMailboxId": "12345",
"status": 429,
"to": "./path/to/file",
"toMailboxId": "v4.0.0-rc.4",
},
"activeChat": true,
"address": "0x1",
"name": "Yusuf Mangunwijaya",
"stored": false,
"textilePubkey": "https://accounts.google.com/o/oauth2/revoke?token=429",
"typingState": "TYPING",
},
]
`;
44 changes: 43 additions & 1 deletion store/friends/mutations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,48 @@ describe('mutate friends', () => {
expect(InitialFriendsState.all).toContainEqual(payload)
})

test('set store true', () => {
const payload: any = {
name: 'Yusuf Mangunwijaya',
address: '0x1',
typingState: 'NOT_TYPING',
activeChat: true, // Change from false (above) to true
account: {
accountId: 'Checking Account',
from: '.',
status: 429,
fromMailboxId: '12345',
toMailboxId: 'v4.0.0-rc.4',
to: './path/to/file',
},
textilePubkey: 'https://accounts.google.com/o/oauth2/revoke?token=429',
}

inst.setStored(InitialFriendsState, payload)
expect(InitialFriendsState.all).toMatchSnapshot()
})

test('set store false', () => {
const payload: any = {
name: 'Yusuf Mangunwijaya',
address: '0x1',
typingState: 'NOT_TYPING',
activeChat: true, // Change from false (above) to true
account: {
accountId: 'Checking Account',
from: '.',
status: 429,
fromMailboxId: '12345',
toMailboxId: 'v4.0.0-rc.4',
to: './path/to/file',
},
textilePubkey: 'https://accounts.google.com/o/oauth2/revoke?token=429',
}

inst.setStored(InitialFriendsState, payload, false)
expect(InitialFriendsState.all).toMatchSnapshot()
})

test('set typing state', () => {
const payload: any = {
name: 'Yusuf Mangunwijaya',
Expand All @@ -492,7 +534,7 @@ describe('mutate friends', () => {
id: payload.address,
typingState: 'TYPING',
})
expect(InitialFriendsState.all).toContainEqual(payload)
expect(InitialFriendsState.all).toMatchSnapshot()
})

test('update friend', () => {
Expand Down

0 comments on commit 4924ddb

Please sign in to comment.