@@ -95,6 +95,54 @@ describe('SimpleTextDisplayer', () => {
9595 [ shakaCue ] ) ;
9696 } ) ;
9797
98+ it ( 'creates style tags for cues with underline/italics/bold' , ( ) => {
99+ const shakaCue = new shaka . text . Cue ( 10 , 20 , '' ) ;
100+
101+ // First cue is underlined and italicized.
102+ const nestedCue1 = new shaka . text . Cue ( 10 , 20 , 'Test1' ) ;
103+ nestedCue1 . fontStyle = shaka . text . Cue . fontStyle . ITALIC ;
104+ nestedCue1 . textDecoration . push ( shaka . text . Cue . textDecoration . UNDERLINE ) ;
105+
106+ // Second cue is italicized and bolded.
107+ const nestedCue2 = new shaka . text . Cue ( 10 , 20 , 'Test2' ) ;
108+ nestedCue2 . fontStyle = shaka . text . Cue . fontStyle . ITALIC ;
109+ nestedCue2 . fontWeight = shaka . text . Cue . fontWeight . BOLD ;
110+
111+ // Third cue has no bold, italics, or underline.
112+ const nestedCue3 = new shaka . text . Cue ( 10 , 20 , 'Test3' ) ;
113+
114+ // Fourth cue is only underlined.
115+ const nestedCue4 = new shaka . text . Cue ( 10 , 20 , 'Test4' ) ;
116+ nestedCue4 . textDecoration . push ( shaka . text . Cue . textDecoration . UNDERLINE ) ;
117+
118+ const expectedText =
119+ '<i><u>Test1</u></i><b><i>Test2</i></b>Test3<u>Test4</u>' ;
120+ shakaCue . nestedCues = [ nestedCue1 , nestedCue2 , nestedCue3 , nestedCue4 ] ;
121+ verifyHelper (
122+ [
123+ { startTime : 10 , endTime : 20 , text : expectedText } ,
124+ ] ,
125+ [ shakaCue ] ) ;
126+ } ) ;
127+
128+ it ( 'adds linebreaks when a linebreak cue is seen' , ( ) => {
129+ const shakaCue = new shaka . text . Cue ( 10 , 20 , '' ) ;
130+ const nestedCue1 = new shaka . text . Cue ( 10 , 20 , 'Test1' ) ;
131+
132+ // Second cue is a linebreak cue.
133+ const nestedCue2 = new shaka . text . Cue ( 10 , 20 , '' ) ;
134+ nestedCue2 . spacer = true ;
135+
136+ const nestedCue3 = new shaka . text . Cue ( 10 , 20 , 'Test2' ) ;
137+
138+ shakaCue . nestedCues = [ nestedCue1 , nestedCue2 , nestedCue3 ] ;
139+ verifyHelper (
140+ [
141+ { startTime : 10 , endTime : 20 , text : 'Test1\nTest2' } ,
142+ ] ,
143+ [ shakaCue ] ) ;
144+ } ) ;
145+
98146 it ( 'skips duplicate cues' , ( ) => {
99147 const cue1 = new shaka . text . Cue ( 10 , 20 , 'Test' ) ;
100148 displayer . append ( [ cue1 ] ) ;
0 commit comments