Skip to content

Commit

Permalink
chore(specs): fix tests that are mocking the entire background state
Browse files Browse the repository at this point in the history
  • Loading branch information
lutangar committed Nov 7, 2019
1 parent 30fcc8a commit fc9cc1c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
4 changes: 4 additions & 0 deletions src/app/background/reducers/bullesUpdate.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ export interface BullesUpdateState {
lastUpdateMessageShowDate: null | Date;
}

export interface BullesUpdateStateSlice {
bullesUpdate: BullesUpdateState;
}

const initialState: BullesUpdateState = {
lastUpdateMessageShowDate: null
};
Expand Down
22 changes: 2 additions & 20 deletions src/app/background/selectors/bullesUpdate.selectors.spec.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
import { BackgroundState } from '../reducers';
import { expect } from 'chai';
import { getUpdateMessageLastShowDate } from './bullesUpdate.selectors';
import { BullesUpdateStateSlice } from '../reducers/bullesUpdate.reducer';

describe('background > selectors > bullesUpdate', () => {
describe('getUpdateMessageLastShowDate', () => {
it("returns the message's last date", () => {
const someDay = new Date('2019-09-13');
const state: BackgroundState = {
tabs: {},
installationDetails: {
version: '',
reason: 'INSTALL'
},
prefs: {
likedNotices: [],
dislikedNotices: [],
dismissedNotices: [],
readNotices: [],
tosAccepted: true
},
resources: {
matchingContexts: [],
drafts: [],
contributors: []
},
subscriptions: [],
const state: BullesUpdateStateSlice = {
bullesUpdate: { lastUpdateMessageShowDate: someDay }
};
expect(getUpdateMessageLastShowDate(state)).to.eql(someDay);
Expand Down
11 changes: 7 additions & 4 deletions src/app/background/selectors/bullesUpdate.selectors.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { createSelector } from 'reselect';
import * as R from 'ramda';
import { BackgroundState } from '../reducers';
import { BullesUpdateState } from '../reducers/bullesUpdate.reducer';
import {
BullesUpdateState,
BullesUpdateStateSlice
} from '../reducers/bullesUpdate.reducer';

const getBullesUpdateState = (state: BackgroundState): BullesUpdateState =>
state.bullesUpdate;
const getBullesUpdateState = (
state: BullesUpdateStateSlice
): BullesUpdateState => state.bullesUpdate;

export const getUpdateMessageLastShowDate = createSelector(
[getBullesUpdateState],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('background > selectors > subscriptions ', () => {
},
resources: {
matchingContexts: [],
restrictedContexts: [],
drafts: [],
contributors: [
contributor1,
Expand Down

0 comments on commit fc9cc1c

Please sign in to comment.