1+ global . extension = {
2+ skeleton : {
3+ main : {
4+ layers : {
5+ section : { }
6+ }
7+ }
8+ }
9+ } ;
10+
11+ global . satus = {
12+ storage : {
13+ get : jest . fn ( )
14+ }
15+ } ;
16+
17+ require ( '../../menu/skeleton-parts/themes.js' ) ;
18+
19+ describe ( 'Themes menu radio state' , ( ) => {
20+ beforeEach ( ( ) => {
21+ jest . clearAllMocks ( ) ;
22+ } ) ;
23+
24+ test ( 'keeps YouTube light as the default option when there is no stored theme' , ( ) => {
25+ satus . storage . get . mockReturnValue ( undefined ) ;
26+
27+ const section = extension . skeleton . main . layers . section . themes . on . click . section ;
28+ const currentTheme = section . default ( ) ;
29+ const oppositeTheme = section . opposite ( ) ;
30+
31+ expect ( currentTheme . text ) . toBe ( 'youtubesLight' ) ;
32+ expect ( currentTheme . radio . value ) . toBe ( 'light' ) ;
33+ expect ( currentTheme . radio . checked ) . toBe ( true ) ;
34+ expect ( oppositeTheme . text ) . toBe ( 'youtubesDark' ) ;
35+ expect ( oppositeTheme . radio . value ) . toBe ( 'dark' ) ;
36+ expect ( oppositeTheme . radio . checked ) . toBeUndefined ( ) ;
37+ } ) ;
38+
39+ test ( 'marks YouTube dark as checked when dark is the current theme' , ( ) => {
40+ satus . storage . get . mockReturnValue ( 'dark' ) ;
41+
42+ const section = extension . skeleton . main . layers . section . themes . on . click . section ;
43+ const currentTheme = section . default ( ) ;
44+ const oppositeTheme = section . opposite ( ) ;
45+
46+ expect ( currentTheme . text ) . toBe ( 'youtubesLight' ) ;
47+ expect ( currentTheme . radio . value ) . toBe ( 'light' ) ;
48+ expect ( currentTheme . radio . checked ) . toBeUndefined ( ) ;
49+ expect ( oppositeTheme . text ) . toBe ( 'youtubesDark' ) ;
50+ expect ( oppositeTheme . radio . value ) . toBe ( 'dark' ) ;
51+ expect ( oppositeTheme . radio . checked ) . toBe ( true ) ;
52+ } ) ;
53+
54+ test ( 'keeps YouTube light selected when light is explicitly stored' , ( ) => {
55+ satus . storage . get . mockReturnValue ( 'light' ) ;
56+
57+ const section = extension . skeleton . main . layers . section . themes . on . click . section ;
58+ const currentTheme = section . default ( ) ;
59+ const oppositeTheme = section . opposite ( ) ;
60+
61+ expect ( currentTheme . radio . value ) . toBe ( 'light' ) ;
62+ expect ( currentTheme . radio . checked ) . toBe ( true ) ;
63+ expect ( oppositeTheme . radio . value ) . toBe ( 'dark' ) ;
64+ expect ( oppositeTheme . radio . checked ) . toBeUndefined ( ) ;
65+ } ) ;
66+ } ) ;
0 commit comments