Browse Source

feature(peers/ticker): add basic tests for reducers

renovate/lint-staged-8.x
Jack Mallers 8 years ago
parent
commit
756c6a2d6c
  1. 155
      test/reducers/__snapshots__/peers.spec.js.snap
  2. 37
      test/reducers/__snapshots__/ticker.spec.js.snap
  3. 42
      test/reducers/peers.spec.js
  4. 37
      test/reducers/ticker.spec.js

155
test/reducers/__snapshots__/peers.spec.js.snap

@ -1,5 +1,160 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`reducers peersReducer should correctly connectFailure 1`] = `
Object {
"connecting": false,
"disconnecting": false,
"peer": null,
"peerForm": Object {
"host": "",
"isOpen": false,
"pubkey": "",
},
"peers": Array [],
"peersLoading": false,
}
`;
exports[`reducers peersReducer should correctly connectFailure 2`] = `
Object {
"connecting": false,
"disconnecting": false,
"peer": null,
"peerForm": Object {
"host": "",
"isOpen": false,
"pubkey": "",
},
"peers": "foo",
"peersLoading": false,
}
`;
exports[`reducers peersReducer should correctly connectPeer 1`] = `
Object {
"connecting": true,
"disconnecting": false,
"peer": null,
"peerForm": Object {
"host": "",
"isOpen": false,
"pubkey": "",
},
"peers": Array [],
"peersLoading": false,
}
`;
exports[`reducers peersReducer should correctly connectSuccess 1`] = `
Object {
"connecting": false,
"disconnecting": false,
"peer": null,
"peerForm": Object {
"host": "",
"isOpen": false,
"pubkey": "",
},
"peers": Array [
"foo",
],
"peersLoading": false,
}
`;
exports[`reducers peersReducer should correctly disconnectFailure 1`] = `
Object {
"connecting": false,
"disconnecting": false,
"peer": null,
"peerForm": Object {
"host": "",
"isOpen": false,
"pubkey": "",
},
"peers": Array [],
"peersLoading": false,
}
`;
exports[`reducers peersReducer should correctly disconnectPeer 1`] = `
Object {
"connecting": false,
"disconnecting": true,
"peer": null,
"peerForm": Object {
"host": "",
"isOpen": false,
"pubkey": "",
},
"peers": Array [],
"peersLoading": false,
}
`;
exports[`reducers peersReducer should correctly disconnectSuccess 1`] = `
Object {
"connecting": false,
"disconnecting": false,
"peer": null,
"peerForm": Object {
"host": "",
"isOpen": false,
"pubkey": "",
},
"peers": Array [],
"peersLoading": false,
}
`;
exports[`reducers peersReducer should correctly getPeers 1`] = `
Object {
"connecting": false,
"disconnecting": false,
"peer": null,
"peerForm": Object {
"host": "",
"isOpen": false,
"pubkey": "",
},
"peers": Array [],
"peersLoading": true,
}
`;
exports[`reducers peersReducer should correctly setPeer 1`] = `
Object {
"connecting": false,
"disconnecting": false,
"peer": "foo",
"peerForm": Object {
"host": "",
"isOpen": false,
"pubkey": "",
},
"peers": Array [],
"peersLoading": false,
}
`;
exports[`reducers peersReducer should correctly setPeerForm 1`] = `
Object {
"connecting": false,
"disconnecting": false,
"peer": null,
"peerForm": Object {
"0": "f",
"1": "o",
"2": "o",
"host": "",
"isOpen": false,
"pubkey": "",
},
"peers": Array [],
"peersLoading": false,
}
`;
exports[`reducers peersReducer should handle initial state 1`] = ` exports[`reducers peersReducer should handle initial state 1`] = `
Object { Object {
"connecting": false, "connecting": false,

37
test/reducers/__snapshots__/ticker.spec.js.snap

@ -0,0 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`reducers tickerReducer should correctly getTicker 1`] = `
Object {
"btcTicker": null,
"crypto": "btc",
"currency": "btc",
"tickerLoading": true,
}
`;
exports[`reducers tickerReducer should correctly receiveTicker 1`] = `
Object {
"btcTicker": "f",
"crypto": "btc",
"currency": "btc",
"tickerLoading": false,
}
`;
exports[`reducers tickerReducer should correctly setCurrency 1`] = `
Object {
"btcTicker": null,
"crypto": "btc",
"currency": "foo",
"tickerLoading": false,
}
`;
exports[`reducers tickerReducer should handle initial state 1`] = `
Object {
"btcTicker": null,
"crypto": "btc",
"currency": "btc",
"tickerLoading": false,
}
`;

42
test/reducers/peers.spec.js

@ -57,8 +57,44 @@ describe('reducers', () => {
expect(RECEIVE_PEERS).toEqual('RECEIVE_PEERS') expect(RECEIVE_PEERS).toEqual('RECEIVE_PEERS')
}) })
// it('should correctly sendPayment', () => { it('should correctly disconnectPeer', () => {
// expect(peersReducer(undefined, { type: SET_PAYMENT, payment: 'foo' })).toMatchSnapshot() expect(peersReducer(undefined, { type: DISCONNECT_PEER })).toMatchSnapshot()
// }) })
it('should correctly disconnectSuccess', () => {
expect(peersReducer(undefined, { type: DISCONNECT_SUCCESS, pubkey: 'foo' })).toMatchSnapshot()
})
it('should correctly disconnectFailure', () => {
expect(peersReducer(undefined, { type: DISCONNECT_FAILURE })).toMatchSnapshot()
})
it('should correctly connectPeer', () => {
expect(peersReducer(undefined, { type: CONNECT_PEER })).toMatchSnapshot()
})
it('should correctly connectSuccess', () => {
expect(peersReducer(undefined, { type: CONNECT_SUCCESS, peer: 'foo' })).toMatchSnapshot()
})
it('should correctly connectFailure', () => {
expect(peersReducer(undefined, { type: CONNECT_FAILURE })).toMatchSnapshot()
})
it('should correctly setPeerForm', () => {
expect(peersReducer(undefined, { type: SET_PEER_FORM, form: 'foo' })).toMatchSnapshot()
})
it('should correctly setPeer', () => {
expect(peersReducer(undefined, { type: SET_PEER, peer: 'foo' })).toMatchSnapshot()
})
it('should correctly getPeers', () => {
expect(peersReducer(undefined, { type: GET_PEERS })).toMatchSnapshot()
})
it('should correctly connectFailure', () => {
expect(peersReducer(undefined, { type: RECEIVE_PEERS, peers: 'foo' })).toMatchSnapshot()
})
}) })
}) })

37
test/reducers/ticker.spec.js

@ -0,0 +1,37 @@
import tickerReducer, {
SET_CURRENCY,
GET_TICKER,
RECIEVE_TICKER
} from '../../app/reducers/ticker'
describe('reducers', () => {
describe('tickerReducer', () => {
it('should handle initial state', () => {
expect(tickerReducer(undefined, {})).toMatchSnapshot()
})
it('should have SET_CURRENCY', () => {
expect(SET_CURRENCY).toEqual('SET_CURRENCY')
})
it('should have GET_TICKER', () => {
expect(GET_TICKER).toEqual('GET_TICKER')
})
it('should have RECIEVE_TICKER', () => {
expect(RECIEVE_TICKER).toEqual('RECIEVE_TICKER')
})
it('should correctly setCurrency', () => {
expect(tickerReducer(undefined, { type: SET_CURRENCY, currency: 'foo' })).toMatchSnapshot()
})
it('should correctly getTicker', () => {
expect(tickerReducer(undefined, { type: GET_TICKER })).toMatchSnapshot()
})
it('should correctly receiveTicker', () => {
expect(tickerReducer(undefined, { type: RECIEVE_TICKER, ticker: 'foo' })).toMatchSnapshot()
})
})
})
Loading…
Cancel
Save