@@ -16,26 +16,26 @@ const taskLocation = TaskLocation.fromUnknownPosition(new TasksFile('anything.md
1616
1717describe ( 'list item tests' , ( ) => {
1818 it ( 'should create list item with empty children and absent parent' , ( ) => {
19- const listItem = ListItem . fromListItemLine ( '' , null , taskLocation ) ! ;
19+ const listItem = ListItem . fromListItemLine ( '- list item ' , null , taskLocation ) ! ;
2020 expect ( listItem ) . toBeDefined ( ) ;
2121 expect ( listItem . children ) . toEqual ( [ ] ) ;
2222 expect ( listItem . parent ) . toEqual ( null ) ;
2323 expect ( listItem . taskLocation ) . toBe ( taskLocation ) ;
2424 } ) ;
2525
2626 it ( 'should create a list item with 2 children' , ( ) => {
27- const listItem = ListItem . fromListItemLine ( '' , null , taskLocation ) ! ;
28- const childItem1 = ListItem . fromListItemLine ( '' , listItem , taskLocation ) ! ;
29- const childItem2 = ListItem . fromListItemLine ( '' , listItem , taskLocation ) ! ;
27+ const listItem = ListItem . fromListItemLine ( '- list item ' , null , taskLocation ) ! ;
28+ const childItem1 = ListItem . fromListItemLine ( '- list item ' , listItem , taskLocation ) ! ;
29+ const childItem2 = ListItem . fromListItemLine ( '- list item ' , listItem , taskLocation ) ! ;
3030 expect ( listItem ) . toBeDefined ( ) ;
3131 expect ( childItem1 . parent ) . toEqual ( listItem ) ;
3232 expect ( childItem2 . parent ) . toEqual ( listItem ) ;
3333 expect ( listItem . children ) . toEqual ( [ childItem1 , childItem2 ] ) ;
3434 } ) ;
3535
3636 it ( 'should create a list item with a parent' , ( ) => {
37- const parentItem = ListItem . fromListItemLine ( '' , null , taskLocation ) ! ;
38- const listItem = ListItem . fromListItemLine ( '' , parentItem , taskLocation ) ! ;
37+ const parentItem = ListItem . fromListItemLine ( '- list item ' , null , taskLocation ) ! ;
38+ const listItem = ListItem . fromListItemLine ( '- list item ' , parentItem , taskLocation ) ! ;
3939 expect ( listItem ) . toBeDefined ( ) ;
4040 expect ( listItem . parent ) . toEqual ( parentItem ) ;
4141 expect ( parentItem . children ) . toEqual ( [ listItem ] ) ;
@@ -149,14 +149,10 @@ describe('list item parsing', () => {
149149 expect ( ListItem . fromListItemLine ( '2. xxx' , null , taskLocation ) ! . listMarker ) . toEqual ( '2.' ) ;
150150 } ) ;
151151
152- it ( 'should accept a non list item' , ( ) => {
153- // we tried making the constructor throw if given a non list item
154- // but it broke lots of normal Task uses in the tests (TaskBuilder)
152+ it ( 'should detect a non-list item' , ( ) => {
155153 const item = ListItem . fromListItemLine ( '# Heading' , null , taskLocation ) ! ;
156154
157- expect ( item . description ) . toEqual ( '# Heading' ) ;
158- expect ( item . originalMarkdown ) . toEqual ( '# Heading' ) ;
159- expect ( item . statusCharacter ) . toEqual ( null ) ;
155+ expect ( item ) . toBeNull ( ) ;
160156 } ) ;
161157} ) ;
162158
0 commit comments