@@ -111,6 +111,84 @@ void main() {
111111 - State "DONE" from "TODO" [2024-01-02 Tue 12:34]
112112''' );
113113 });
114+ group ('custom states' , () {
115+ group ('manual example' , () {
116+ final todoStates = [
117+ OrgTodoStates (
118+ todo: ['TODO' , 'FEEDBACK' , 'VERIFY' ],
119+ done: ['DONE' , 'CANCELED' ])
120+ ];
121+ final parser = OrgParserDefinition (todoStates: todoStates).build ();
122+ test ('next not done' , () {
123+ final now = DateTime (2024 , 2 , 3 , 23 , 45 );
124+ final result = parser.parse ('''* TODO foo
125+ SCHEDULED: <2024-01-01 Mon +1w>
126+ :PROPERTIES:
127+ :LAST_REPEAT: [2024-01-02 Tue 12:34]
128+ :END:
129+ - State "DONE" from "TODO" [2024-01-02 Tue 12:34]
130+ ''' );
131+ final doc = result.value as OrgDocument ;
132+ final section = doc.sections[0 ];
133+ final updated = section.cycleTodo (now: now, todoStates: todoStates);
134+ expect (updated.toMarkup (), '''* FEEDBACK foo
135+ SCHEDULED: <2024-01-08 Mon +1w>
136+ :PROPERTIES:
137+ :LAST_REPEAT: [2024-01-02 Tue 12:34]
138+ :END:
139+ - State "DONE" from "TODO" [2024-01-02 Tue 12:34]
140+ ''' );
141+ });
142+ test ('next just one of done' , () {
143+ final now = DateTime (2024 , 2 , 3 , 23 , 45 );
144+ final result = parser.parse ('''* VERIFY foo
145+ SCHEDULED: <2024-01-01 Mon +1w>
146+ :PROPERTIES:
147+ :LAST_REPEAT: [2024-01-02 Tue 12:34]
148+ :END:
149+ - State "DONE" from "TODO" [2024-01-02 Tue 12:34]
150+ ''' );
151+ final doc = result.value as OrgDocument ;
152+ final section = doc.sections[0 ];
153+ final updated = section.cycleTodo (now: now, todoStates: todoStates);
154+ expect (updated.toMarkup (), '''* TODO foo
155+ SCHEDULED: <2024-01-08 Mon +1w>
156+ :PROPERTIES:
157+ :LAST_REPEAT: [2024-02-03 Sat 23:45]
158+ :END:
159+ - State "DONE" from "VERIFY" [2024-02-03 Sat 23:45]
160+ - State "DONE" from "TODO" [2024-01-02 Tue 12:34]
161+ ''' );
162+ });
163+ });
164+ group ('no todo states' , () {
165+ final todoStates = [
166+ OrgTodoStates (todo: [], done: ['TODO' ])
167+ ];
168+ final parser = OrgParserDefinition (todoStates: todoStates).build ();
169+ test ('from empty' , () {
170+ final now = DateTime (2024 , 2 , 3 , 23 , 45 );
171+ final result = parser.parse ('''* foo
172+ SCHEDULED: <2024-01-01 Mon +1w>
173+ :PROPERTIES:
174+ :LAST_REPEAT: [2024-01-02 Tue 12:34]
175+ :END:
176+ - State "DONE" from "TODO" [2024-01-02 Tue 12:34]
177+ ''' );
178+ final doc = result.value as OrgDocument ;
179+ final section = doc.sections[0 ];
180+ final updated = section.cycleTodo (now: now, todoStates: todoStates);
181+ expect (updated.toMarkup (), '''* foo
182+ SCHEDULED: <2024-01-08 Mon +1w>
183+ :PROPERTIES:
184+ :LAST_REPEAT: [2024-02-03 Sat 23:45]
185+ :END:
186+ - State "TODO" from "" [2024-02-03 Sat 23:45]
187+ - State "DONE" from "TODO" [2024-01-02 Tue 12:34]
188+ ''' );
189+ });
190+ });
191+ });
114192 });
115193 });
116194 group ('set property' , () {
0 commit comments