@@ -38,13 +38,43 @@ describe('Markular', () => {
3838 expect ( component . _val ) . toBe ( '# Hello' ) ;
3939 } ) ;
4040
41+ it ( 'should insert H1 when subselect' , ( ) => {
42+ component . _val = 'Hello' ;
43+ component . selStart = 2 ;
44+ component . selEnd = 3 ;
45+ component . toggleHeading ( 1 ) ;
46+ expect ( component . _val ) . toBe ( 'He# llo' ) ;
47+ } ) ;
48+
49+ it ( 'should insert H1 when none selected' , ( ) => {
50+ component . _val = 'Hello' ;
51+ component . selStart = 3 ;
52+ component . selEnd = 3 ;
53+ component . toggleHeading ( 1 ) ;
54+ expect ( component . _val ) . toBe ( '# Hello' ) ;
55+ } ) ;
56+
4157 it ( 'should be H1' , ( ) => {
4258 component . _val = '# Hello' ;
4359 component . selStart = 0 ;
4460 component . selEnd = 7 ;
4561 expect ( component . isHeading ( 1 ) ) . toBeTruthy ( ) ;
4662 } ) ;
4763
64+ it ( 'should be H1 when none selected' , ( ) => {
65+ component . _val = '# Hello' ;
66+ component . selStart = 5 ;
67+ component . selEnd = 5 ;
68+ expect ( component . isHeading ( 1 ) ) . toBeTruthy ( ) ;
69+ } ) ;
70+
71+ it ( 'should not be H1 when subselect' , ( ) => {
72+ component . _val = '# Hello' ;
73+ component . selStart = 3 ;
74+ component . selEnd = 5 ;
75+ expect ( component . isHeading ( 1 ) ) . toBeFalsy ( ) ;
76+ } ) ;
77+
4878 it ( 'should remove H1' , ( ) => {
4979 component . _val = '# Hello' ;
5080 component . selStart = 0 ;
@@ -136,6 +166,22 @@ describe('Markular', () => {
136166 expect ( component . _val ) . toBe ( '- Hello' ) ;
137167 } ) ;
138168
169+ it ( 'should insert ul when subselect' , ( ) => {
170+ component . _val = 'Hello' ;
171+ component . selStart = 2 ;
172+ component . selEnd = 3 ;
173+ component . toggleUnorderedList ( ) ;
174+ expect ( component . _val ) . toBe ( 'He- llo' ) ;
175+ } ) ;
176+
177+ it ( 'should insert ul when none selected' , ( ) => {
178+ component . _val = 'Hello' ;
179+ component . selStart = 3 ;
180+ component . selEnd = 3 ;
181+ component . toggleUnorderedList ( ) ;
182+ expect ( component . _val ) . toBe ( '- Hello' ) ;
183+ } ) ;
184+
139185 it ( 'should insert ul multiline' , ( ) => {
140186 component . _val = 'Hello\nWorld' ;
141187 component . selStart = 0 ;
@@ -151,13 +197,27 @@ describe('Markular', () => {
151197 expect ( component . isUnorderedList ( ) ) . toBeTruthy ( ) ;
152198 } ) ;
153199
200+ it ( 'should be ul none selected' , ( ) => {
201+ component . _val = '- Hello' ;
202+ component . selStart = 6 ;
203+ component . selEnd = 6 ;
204+ expect ( component . isUnorderedList ( ) ) . toBeTruthy ( ) ;
205+ } ) ;
206+
154207 it ( 'should be ul multiline' , ( ) => {
155208 component . _val = '- Hello\n- World' ;
156209 component . selStart = 0 ;
157210 component . selEnd = 11 ;
158211 expect ( component . isUnorderedList ( ) ) . toBeTruthy ( ) ;
159212 } ) ;
160213
214+ it ( 'should not be ul when subselect' , ( ) => {
215+ component . _val = '- Hello' ;
216+ component . selStart = 4 ;
217+ component . selEnd = 6 ;
218+ expect ( component . isUnorderedList ( ) ) . toBeFalsy ( ) ;
219+ } ) ;
220+
161221 it ( 'should remove ul' , ( ) => {
162222 component . _val = '- Hello' ;
163223 component . selStart = 0 ;
@@ -208,6 +268,22 @@ describe('Markular', () => {
208268 expect ( component . _val ) . toBe ( '1. Hello' ) ;
209269 } ) ;
210270
271+ it ( 'should insert ol when subselect' , ( ) => {
272+ component . _val = 'Hello' ;
273+ component . selStart = 2 ;
274+ component . selEnd = 3 ;
275+ component . toggleOrderedList ( ) ;
276+ expect ( component . _val ) . toBe ( 'He1. llo' ) ;
277+ } ) ;
278+
279+ it ( 'should insert ol when none selected' , ( ) => {
280+ component . _val = 'Hello' ;
281+ component . selStart = 3 ;
282+ component . selEnd = 3 ;
283+ component . toggleOrderedList ( ) ;
284+ expect ( component . _val ) . toBe ( '1. Hello' ) ;
285+ } ) ;
286+
211287 it ( 'should insert ol multiline' , ( ) => {
212288 component . _val = 'Hello\nWorld' ;
213289 component . selStart = 0 ;
@@ -223,13 +299,27 @@ describe('Markular', () => {
223299 expect ( component . isOrderedList ( ) ) . toBeTruthy ( ) ;
224300 } ) ;
225301
302+ it ( 'should be ol none selected' , ( ) => {
303+ component . _val = '1. Hello' ;
304+ component . selStart = 6 ;
305+ component . selEnd = 6 ;
306+ expect ( component . isOrderedList ( ) ) . toBeTruthy ( ) ;
307+ } ) ;
308+
226309 it ( 'should be ol multiline' , ( ) => {
227310 component . _val = '1. Hello\n2. World' ;
228311 component . selStart = 0 ;
229312 component . selEnd = 13 ;
230313 expect ( component . isOrderedList ( ) ) . toBeTruthy ( ) ;
231314 } ) ;
232315
316+ it ( 'should not be ol when subselect' , ( ) => {
317+ component . _val = '1. Hello' ;
318+ component . selStart = 4 ;
319+ component . selEnd = 6 ;
320+ expect ( component . isOrderedList ( ) ) . toBeFalsy ( ) ;
321+ } ) ;
322+
233323 it ( 'should remove ol' , ( ) => {
234324 component . _val = '1. Hello' ;
235325 component . selStart = 0 ;
0 commit comments