Skip to content

Commit dbaff9d

Browse files
chrisbobbegnprice
authored andcommitted
fetchActions tests: Don't spread value with opaque PerAccountState type
With Flow v0.175.1, which we'd like to upgrade to soon, we'd get this error: ``` Error ---------------------------------------------------------------- src/message/__tests__/fetchActions-test.js:312:37 Cannot spread object literal because `PerAccountState` [1] is not an object. [not-an-object] src/message/__tests__/fetchActions-test.js:312:37 v 312| const stateWithoutAccount = { 313| ...baseState, 314| accounts: [], 315| }; ^ References: src/__tests__/lib/exampleData.js:684:18 684| ): GlobalState & PerAccountState => ^^^^^^^^^^^^^^^ [1] ``` Probably to do with `PerAccountState` being opaque. (The `baseState` value is returned by `eg.reduxStatePlus`, so it's a `GlobalState & PerAccountState`.) Fortunately it's easy to fix: this test is checking what happens when a normal, boring message fetch happens when there isn't a logged-in account to handle the payload. We can simulate that state by making `state.accounts` empty, without touching other state subtrees.
1 parent 4a22417 commit dbaff9d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/message/__tests__/fetchActions-test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,9 @@ describe('fetchActions', () => {
309309
});
310310

311311
test('rejects when user is not logged in, dispatches MESSAGE_FETCH_ERROR', async () => {
312-
const stateWithoutAccount = {
313-
...baseState,
312+
const stateWithoutAccount = eg.reduxStatePlus({
314313
accounts: [],
315-
};
314+
});
316315
const store = mockStore<GlobalState, Action>(stateWithoutAccount);
317316

318317
const response = {

0 commit comments

Comments
 (0)