Skip to content

Commit

Permalink
dev: Remove outdated event sorting test
Browse files Browse the repository at this point in the history
  • Loading branch information
kschiffer committed Oct 1, 2020
1 parent 3c2eaeb commit fa1a9f6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 79 deletions.
72 changes: 0 additions & 72 deletions pkg/webui/console/store/reducers/tests/events_test.js

This file was deleted.

51 changes: 44 additions & 7 deletions pkg/webui/console/store/reducers/tests/gateway-status_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ import reducer, { defaultState } from '../gateway-status'
import {
getGateway,
updateGatewayStatisticsSuccess,
getGatewayEventMessageSuccess,
getGatewayEventMessagesSuccess,
} from '../../actions/gateways'

const genericEvent = {
identifiers: [{ gateway_ids: { gateway_id: 'test-gateway-id' } }],
name: 'gateway.update',
time: '2020-04-23T09:41:04.134034132Z',
unique_id: '01EK2PTJ6J42DKWGC2F3PZ32TM',
}

describe('Gateway-status reducer', () => {
it('returns the initial state', () => {
expect(reducer(undefined, { type: '@@TEST_INIT', payload: {} })).toEqual(defaultState)
Expand Down Expand Up @@ -118,7 +125,7 @@ describe('Gateway-status reducer', () => {
time: '2019-09-24T13:40:30.033728431Z',
}

newState = reducer(defaultState, getGatewayEventMessageSuccess('test-gtw-id', event))
newState = reducer(defaultState, getGatewayEventMessagesSuccess('test-gtw-id', [event]))
expect(newState !== defaultState).toBe(true)
expect(newState.lastSeen).toBeDefined()
expect(newState.lastSeen).toStrictEqual(new Date(event.time))
Expand All @@ -130,7 +137,22 @@ describe('Gateway-status reducer', () => {
time: '2019-09-24T13:45:30.033728431Z',
}

newState = reducer(newState, getGatewayEventMessageSuccess('test-gtw-id', event))
newState = reducer(newState, getGatewayEventMessagesSuccess('test-gtw-id', [event]))
expect(newState !== defaultState).toBe(true)
expect(newState.lastSeen).toBeDefined()
expect(newState.lastSeen).toStrictEqual(new Date(event.time))
})

it('updates `lastSeen` on most recent uplink event when dispatching multiple events', () => {
const event = {
name: 'gs.up.receive',
time: '2019-09-24T13:50:30.033728431Z',
}

newState = reducer(
newState,
getGatewayEventMessagesSuccess('test-gtw-id', [genericEvent, event]),
)
expect(newState !== defaultState).toBe(true)
expect(newState.lastSeen).toBeDefined()
expect(newState.lastSeen).toStrictEqual(new Date(event.time))
Expand All @@ -142,7 +164,7 @@ describe('Gateway-status reducer', () => {
time: '2019-09-24T13:30:30.033728431Z',
}

newState = reducer(newState, getGatewayEventMessageSuccess('test-gtw-id', event))
newState = reducer(newState, getGatewayEventMessagesSuccess('test-gtw-id', [event]))
expect(newState !== defaultState).toBe(true)
expect(newState.lastSeen).toBeDefined()
expect(newState.lastSeen).not.toStrictEqual(new Date(event.time))
Expand All @@ -154,7 +176,7 @@ describe('Gateway-status reducer', () => {
time: '2019-09-24T13:50:30.033728431Z',
}

newState = reducer(newState, getGatewayEventMessageSuccess('test-gtw-id', event))
newState = reducer(newState, getGatewayEventMessagesSuccess('test-gtw-id', [event]))
expect(newState !== defaultState).toBe(true)
expect(newState.lastSeen).toBeDefined()
expect(newState.lastSeen).toStrictEqual(new Date(event.time))
Expand All @@ -166,7 +188,22 @@ describe('Gateway-status reducer', () => {
time: '2019-09-24T13:55:30.033728431Z',
}

newState = reducer(newState, getGatewayEventMessageSuccess('test-gtw-id', event))
newState = reducer(newState, getGatewayEventMessagesSuccess('test-gtw-id', [event]))
expect(newState !== defaultState).toBe(true)
expect(newState.lastSeen).toBeDefined()
expect(newState.lastSeen).toStrictEqual(new Date(event.time))
})

it('updates `lastSeen` on most recent status event when dispatching multiple events', () => {
const event = {
name: 'gs.status.receive',
time: '2019-09-24T13:59:30.033728431Z',
}

newState = reducer(
newState,
getGatewayEventMessagesSuccess('test-gtw-id', [genericEvent, event]),
)
expect(newState !== defaultState).toBe(true)
expect(newState.lastSeen).toBeDefined()
expect(newState.lastSeen).toStrictEqual(new Date(event.time))
Expand All @@ -178,7 +215,7 @@ describe('Gateway-status reducer', () => {
time: '2019-09-24T13:35:30.033728431Z',
}

newState = reducer(newState, getGatewayEventMessageSuccess('test-gtw-id', event))
newState = reducer(newState, getGatewayEventMessagesSuccess('test-gtw-id', [event]))
expect(newState !== defaultState).toBe(true)
expect(newState.lastSeen).toBeDefined()
expect(newState.lastSeen).not.toStrictEqual(new Date(event.time))
Expand Down

0 comments on commit fa1a9f6

Please sign in to comment.