@@ -3,7 +3,9 @@ import log from 'electron-log'
33import migrations from '../../../../main/store/migrations'
44import { getDefaultAccountName } from '../../../../resources/domain/account'
55import { capitalize } from '../../../../resources/utils'
6- import { withPlatform } from '../../../util'
6+ import { isWindows } from '../../../../resources/platform'
7+
8+ jest . mock ( '../../../../resources/platform' )
79
810let state
911
@@ -1480,6 +1482,9 @@ describe('migration 35', () => {
14801482describe ( 'migration 37' , ( ) => {
14811483 beforeEach ( ( ) => {
14821484 state . main . _version = 36
1485+ state . main . shortcuts = {
1486+ summon : { modifierKeys : [ 'Alt' ] , shortcutKey : 'Slash' , enabled : true , configuring : false }
1487+ }
14831488 } )
14841489
14851490 describe ( 'when altGr is a modifier' , ( ) => {
@@ -1490,75 +1495,112 @@ describe('migration 37', () => {
14901495 } )
14911496
14921497 it ( 'should update the summon shortcut on Linux' , ( ) => {
1493- withPlatform ( 'linux' , ( ) => {
1494- const updatedState = migrations . apply ( state , 37 )
1495- const { shortcuts } = updatedState . main
1496-
1497- expect ( shortcuts ) . toStrictEqual ( {
1498- summon : {
1499- modifierKeys : [ 'Alt' ] ,
1500- shortcutKey : 'Slash' ,
1501- enabled : true ,
1502- configuring : false
1503- }
1504- } )
1498+ isWindows . mockReturnValue ( false )
1499+
1500+ const updatedState = migrations . apply ( state , 37 )
1501+ const { shortcuts } = updatedState . main
1502+
1503+ expect ( shortcuts ) . toStrictEqual ( {
1504+ summon : {
1505+ modifierKeys : [ 'Alt' ] ,
1506+ shortcutKey : 'Slash' ,
1507+ enabled : true ,
1508+ configuring : false
1509+ }
15051510 } )
15061511 } )
15071512
15081513 it ( 'should update the summon shortcut on Windows' , ( ) => {
1509- withPlatform ( 'win32' , ( ) => {
1510- const updatedState = migrations . apply ( state , 37 )
1511- const { shortcuts } = updatedState . main
1512-
1513- expect ( shortcuts ) . toStrictEqual ( {
1514- summon : {
1515- modifierKeys : [ 'Alt' , 'Control' ] ,
1516- shortcutKey : 'Slash' ,
1517- enabled : true ,
1518- configuring : false
1519- }
1520- } )
1514+ isWindows . mockReturnValue ( true )
1515+
1516+ const updatedState = migrations . apply ( state , 37 )
1517+ const { shortcuts } = updatedState . main
1518+
1519+ expect ( shortcuts ) . toStrictEqual ( {
1520+ summon : {
1521+ modifierKeys : [ 'Alt' , 'Control' ] ,
1522+ shortcutKey : 'Slash' ,
1523+ enabled : true ,
1524+ configuring : false
1525+ }
15211526 } )
15221527 } )
15231528 } )
15241529
1525- describe ( 'when altGr is not a modifier' , ( ) => {
1526- beforeEach ( ( ) => {
1527- state . main . shortcuts = {
1528- summon : { modifierKeys : [ 'Alt' ] , shortcutKey : 'Slash' , enabled : true , configuring : false }
1530+ it ( 'should not update the summon shortcut on Windows' , ( ) => {
1531+ isWindows . mockReturnValue ( true )
1532+
1533+ const updatedState = migrations . apply ( state , 37 )
1534+ const { shortcuts } = updatedState . main
1535+
1536+ expect ( shortcuts ) . toStrictEqual ( {
1537+ summon : {
1538+ modifierKeys : [ 'Alt' ] ,
1539+ shortcutKey : 'Slash' ,
1540+ enabled : true ,
1541+ configuring : false
15291542 }
15301543 } )
1544+ } )
15311545
1532- it ( 'should not update the summon shortcut on Windows' , ( ) => {
1533- withPlatform ( 'win32' , ( ) => {
1534- const updatedState = migrations . apply ( state , 37 )
1535- const { shortcuts } = updatedState . main
1536-
1537- expect ( shortcuts ) . toStrictEqual ( {
1538- summon : {
1539- modifierKeys : [ 'Alt' ] ,
1540- shortcutKey : 'Slash' ,
1541- enabled : true ,
1542- configuring : false
1543- }
1544- } )
1545- } )
1546+ it ( 'should not update the summon shortcut on Linux' , ( ) => {
1547+ isWindows . mockReturnValue ( false )
1548+
1549+ const updatedState = migrations . apply ( state , 37 )
1550+ const { shortcuts } = updatedState . main
1551+
1552+ expect ( shortcuts ) . toStrictEqual ( {
1553+ summon : {
1554+ modifierKeys : [ 'Alt' ] ,
1555+ shortcutKey : 'Slash' ,
1556+ enabled : true ,
1557+ configuring : false
1558+ }
1559+ } )
1560+ } )
1561+
1562+ it ( 'should handle missing shortcuts' , ( ) => {
1563+ delete state . main . shortcuts
1564+ const updatedState = migrations . apply ( state , 37 )
1565+ const { shortcuts } = updatedState . main
1566+
1567+ expect ( shortcuts ) . toStrictEqual ( {
1568+ summon : {
1569+ modifierKeys : [ 'Alt' ] ,
1570+ shortcutKey : 'Slash' ,
1571+ enabled : true ,
1572+ configuring : false
1573+ }
15461574 } )
1575+ } )
15471576
1548- it ( 'should not update the summon shortcut on Linux' , ( ) => {
1549- withPlatform ( 'linux' , ( ) => {
1550- const updatedState = migrations . apply ( state , 37 )
1551- const { shortcuts } = updatedState . main
1552-
1553- expect ( shortcuts ) . toStrictEqual ( {
1554- summon : {
1555- modifierKeys : [ 'Alt' ] ,
1556- shortcutKey : 'Slash' ,
1557- enabled : true ,
1558- configuring : false
1559- }
1560- } )
1561- } )
1577+ it ( 'should handle missing shortcuts.summon' , ( ) => {
1578+ delete state . main . shortcuts . summon
1579+ const updatedState = migrations . apply ( state , 37 )
1580+ const { shortcuts } = updatedState . main
1581+
1582+ expect ( shortcuts ) . toStrictEqual ( {
1583+ summon : {
1584+ modifierKeys : [ 'Alt' ] ,
1585+ shortcutKey : 'Slash' ,
1586+ enabled : true ,
1587+ configuring : false
1588+ }
1589+ } )
1590+ } )
1591+
1592+ it ( 'should handle missing shortcuts.summon.modifierKeys' , ( ) => {
1593+ delete state . main . shortcuts . summon . modifierKeys
1594+ const updatedState = migrations . apply ( state , 37 )
1595+ const { shortcuts } = updatedState . main
1596+
1597+ expect ( shortcuts ) . toStrictEqual ( {
1598+ summon : {
1599+ modifierKeys : [ 'Alt' ] ,
1600+ shortcutKey : 'Slash' ,
1601+ enabled : true ,
1602+ configuring : false
1603+ }
15621604 } )
15631605 } )
15641606} )
0 commit comments