-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(options): browser icon bypasses TOS acceptation (#439)
- Loading branch information
1 parent
283e9be
commit be25714
Showing
7 changed files
with
49 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 12 additions & 8 deletions
20
...tore/reducers/tosAccepted.reducer.spec.ts → ...ptions/store/reducers/tos.reducer.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
/* eslint-disable no-unused-expressions, @typescript-eslint/ban-ts-ignore */ | ||
import { expect } from 'chai'; | ||
import { tosAccepted, transmitTosStatus } from 'app/actions'; | ||
import tosAcceptedReducer from './tosAccepted.reducer'; | ||
import tosAcceptedReducer from './tos.reducer'; | ||
|
||
describe('options > reducers > tosAccepted', function() { | ||
// @ts-ignore | ||
const initialState = tosAcceptedReducer(undefined, { type: 'UNKNOWN' }); | ||
|
||
it('is false initially', () => { | ||
expect(initialState).to.be.false; | ||
it('is empty initially', () => { | ||
expect(initialState).to.eql({}); | ||
}); | ||
it('saves true on TOS_ACCEPTED', () => { | ||
expect(tosAcceptedReducer(initialState, tosAccepted({}))).to.be.true; | ||
expect(tosAcceptedReducer(initialState, tosAccepted({}))).to.be.eql({ | ||
tosAccepted: true | ||
}); | ||
}); | ||
it('saves given value on TRANSMIT_TOS_STATUS', () => { | ||
expect(tosAcceptedReducer(initialState, transmitTosStatus(false))).to.be | ||
.false; | ||
expect(tosAcceptedReducer(initialState, transmitTosStatus(true))).to.be | ||
.true; | ||
expect( | ||
tosAcceptedReducer(initialState, transmitTosStatus(false)) | ||
).to.be.eql({ tosAccepted: false }); | ||
expect(tosAcceptedReducer(initialState, transmitTosStatus(true))).to.be.eql( | ||
{ tosAccepted: true } | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as R from 'ramda'; | ||
import { AppAction, TRANSMIT_TOS_STATUS } from 'app/actions'; | ||
|
||
export interface TosState { | ||
tosAccepted?: boolean; | ||
} | ||
|
||
export default (state: TosState = {}, action: AppAction): TosState => { | ||
switch (action.type) { | ||
case 'TOS_ACCEPTED': | ||
return R.assoc('tosAccepted', true, state); | ||
case TRANSMIT_TOS_STATUS: | ||
return R.assoc('tosAccepted', action.payload, state); | ||
default: | ||
return state; | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
import { TosAcceptedState } from '../reducers/tosAccepted.reducer'; | ||
import { TosState } from '../reducers/tos.reducer'; | ||
|
||
export const areTosAccepted = (state: { tosAccepted: TosAcceptedState }) => | ||
state.tosAccepted; | ||
interface StateWithTos { | ||
tos: TosState; | ||
} | ||
|
||
export const areTosAccepted = (state: StateWithTos) => state.tos.tosAccepted; |