2
2
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
3
* You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
5
- import { defaultState , migrateStackWidgetSettings } from '../../../brave_new_tab_ui/storage/new_tab_storage'
5
+ import { defaultState , migrateStackWidgetSettings , replaceStackWidgets } from '../../../brave_new_tab_ui/storage/new_tab_storage'
6
6
7
7
describe ( 'new tab storage' , ( ) => {
8
- describe ( 'cleanData ' , ( ) => {
8
+ describe ( 'migrateStackWidgetSettings ' , ( ) => {
9
9
it ( 'migrates users who had all stack widgets hidden' , ( ) => {
10
10
// showRewards and showBinance are false in default state
11
11
// currentStackWidget will still be set in the event both
@@ -22,73 +22,89 @@ describe('new tab storage', () => {
22
22
}
23
23
expect ( migrateStackWidgetSettings ( initialState ) ) . toEqual ( expectedState )
24
24
} )
25
- } )
26
25
27
- it ( 'migrates users who were showing rewards and hiding binance' , ( ) => {
28
- const initialState = {
29
- ...defaultState ,
30
- currentStackWidget : 'rewards' ,
31
- showRewards : true
32
- }
33
- const expectedState = {
34
- ...defaultState ,
35
- showRewards : true ,
36
- currentStackWidget : '' ,
37
- widgetStackOrder : [ 'rewards' ] ,
38
- removedStackWidgets : [ 'binance' ]
39
- }
40
- expect ( migrateStackWidgetSettings ( initialState ) ) . toEqual ( expectedState )
41
- } )
26
+ it ( 'migrates users who were showing rewards and hiding binance' , ( ) => {
27
+ const initialState = {
28
+ ...defaultState ,
29
+ currentStackWidget : 'rewards' ,
30
+ showRewards : true
31
+ }
32
+ const expectedState = {
33
+ ...defaultState ,
34
+ showRewards : true ,
35
+ currentStackWidget : '' ,
36
+ widgetStackOrder : [ 'rewards' ] ,
37
+ removedStackWidgets : [ 'binance' ]
38
+ }
39
+ expect ( migrateStackWidgetSettings ( initialState ) ) . toEqual ( expectedState )
40
+ } )
42
41
43
- it ( 'migrates users who were showing binance and hiding rewards' , ( ) => {
44
- const initialState = {
45
- ...defaultState ,
46
- currentStackWidget : 'binance' ,
47
- showBinance : true
48
- }
49
- const expectedState = {
50
- ...defaultState ,
51
- showBinance : true ,
52
- currentStackWidget : '' ,
53
- widgetStackOrder : [ 'binance' ] ,
54
- removedStackWidgets : [ 'rewards' ]
55
- }
56
- expect ( migrateStackWidgetSettings ( initialState ) ) . toEqual ( expectedState )
57
- } )
42
+ it ( 'migrates users who were showing binance and hiding rewards' , ( ) => {
43
+ const initialState = {
44
+ ...defaultState ,
45
+ currentStackWidget : 'binance' ,
46
+ showBinance : true
47
+ }
48
+ const expectedState = {
49
+ ...defaultState ,
50
+ showBinance : true ,
51
+ currentStackWidget : '' ,
52
+ widgetStackOrder : [ 'binance' ] ,
53
+ removedStackWidgets : [ 'rewards' ]
54
+ }
55
+ expect ( migrateStackWidgetSettings ( initialState ) ) . toEqual ( expectedState )
56
+ } )
57
+
58
+ it ( 'preserves order and migrates users who were showing both widgets (Binance foreground)' , ( ) => {
59
+ const initialState = {
60
+ ...defaultState ,
61
+ currentStackWidget : 'binance' ,
62
+ showBinance : true ,
63
+ showRewards : true
64
+ }
65
+ const expectedState = {
66
+ ...defaultState ,
67
+ showBinance : true ,
68
+ showRewards : true ,
69
+ currentStackWidget : '' ,
70
+ widgetStackOrder : [ 'rewards' , 'binance' ] ,
71
+ removedStackWidgets : [ ]
72
+ }
73
+ expect ( migrateStackWidgetSettings ( initialState ) ) . toEqual ( expectedState )
74
+ } )
58
75
59
- it ( 'preserves order and migrates users who were showing both widgets (Binance foreground)' , ( ) => {
60
- const initialState = {
61
- ...defaultState ,
62
- currentStackWidget : 'binance' ,
63
- showBinance : true ,
64
- showRewards : true
65
- }
66
- const expectedState = {
67
- ...defaultState ,
68
- showBinance : true ,
69
- showRewards : true ,
70
- currentStackWidget : '' ,
71
- widgetStackOrder : [ 'rewards' , 'binance' ] ,
72
- removedStackWidgets : [ ]
73
- }
74
- expect ( migrateStackWidgetSettings ( initialState ) ) . toEqual ( expectedState )
76
+ it ( 'preserves order and migrates users who were showing both widgets (Rewards foreground)' , ( ) => {
77
+ const initialState = {
78
+ ...defaultState ,
79
+ currentStackWidget : 'rewards' ,
80
+ showBinance : true ,
81
+ showRewards : true
82
+ }
83
+ const expectedState = {
84
+ ...defaultState ,
85
+ showBinance : true ,
86
+ showRewards : true ,
87
+ currentStackWidget : '' ,
88
+ widgetStackOrder : [ 'binance' , 'rewards' ] ,
89
+ removedStackWidgets : [ ]
90
+ }
91
+ expect ( migrateStackWidgetSettings ( initialState ) ) . toEqual ( expectedState )
92
+ } )
75
93
} )
76
94
77
- it ( 'preserves order and migrates users who were showing both widgets (Rewards foreground)' , ( ) => {
78
- const initialState = {
79
- ...defaultState ,
80
- currentStackWidget : 'rewards' ,
81
- showBinance : true ,
82
- showRewards : true
83
- }
84
- const expectedState = {
85
- ...defaultState ,
86
- showBinance : true ,
87
- showRewards : true ,
88
- currentStackWidget : '' ,
89
- widgetStackOrder : [ 'binance' , 'rewards' ] ,
90
- removedStackWidgets : [ ]
91
- }
92
- expect ( migrateStackWidgetSettings ( initialState ) ) . toEqual ( expectedState )
95
+ describe ( 'replaceStackWidgets' , ( ) => {
96
+ it ( 'adds back widgets that should be showing in the stack' , ( ) => {
97
+ const initialState = {
98
+ ...defaultState ,
99
+ showBinance : true ,
100
+ showRewards : true ,
101
+ widgetStackOrder : [ 'binance' ]
102
+ }
103
+ const expectedState = {
104
+ ...initialState ,
105
+ widgetStackOrder : [ 'rewards' , 'binance' ]
106
+ }
107
+ expect ( replaceStackWidgets ( initialState ) ) . toEqual ( expectedState )
108
+ } )
93
109
} )
94
110
} )
0 commit comments