summaryrefslogtreecommitdiff
path: root/tests/issue.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/issue.scm')
-rw-r--r--tests/issue.scm38
1 files changed, 34 insertions, 4 deletions
diff --git a/tests/issue.scm b/tests/issue.scm
index 22982db..97541a0 100644
--- a/tests/issue.scm
+++ b/tests/issue.scm
@@ -1,5 +1,5 @@
;;; tissue --- Text based issue tracker
-;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2022, 2023 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; This file is part of tissue.
;;;
@@ -19,6 +19,7 @@
(import (rnrs hashtables)
(srfi srfi-64)
(srfi srfi-71)
+ (ice-9 match)
(tissue issue))
(define hashtable-prepend!
@@ -31,10 +32,20 @@
(@@ (tissue issue) file-details))
(define (hashtable->alist hashtable)
+ "Convert @var{hashtable} to association list with keys sorted as
+strings."
(let ((keys values (hashtable-entries hashtable)))
- (map cons
- (vector->list keys)
- (vector->list values))))
+ (sort (map cons
+ (vector->list keys)
+ (vector->list values))
+ (match-lambda*
+ (((key1 . _) (key2 . _))
+ (let ((maybe-symbol->string (lambda (x)
+ (if (symbol? x)
+ (symbol->string x)
+ x))))
+ (string<? (maybe-symbol->string key1)
+ (maybe-symbol->string key2))))))))
(test-begin "issue")
@@ -75,4 +86,23 @@
(call-with-input-string "* keywords: this is a long keyword"
(compose hashtable->alist file-details)))
+(test-equal "Parse checkboxes"
+ '((completed-tasks . 1)
+ (tasks . 2))
+ (call-with-input-string "* [ ] foo
+* [x] bar"
+ (compose hashtable->alist file-details)))
+
+(test-equal "Allow checkboxes without a space"
+ '((tasks . 1))
+ (call-with-input-string "* [] foo"
+ (compose hashtable->alist file-details)))
+
+(test-equal "Ignore preformatted block"
+ '()
+ (call-with-input-string "```
+# foo
+```"
+ (compose hashtable->alist file-details)))
+
(test-end "issue")