aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-fixtures.el
blob: dfd9e1d86c5849d3f005c09549c0cb785fff78d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;;; test-pearl-fixtures.el --- smoke tests for the API fixtures -*- lexical-binding: t; -*-

;; Copyright (C) 2026 Craig Jennings

;; Author: Craig Jennings <c@cjennings.net>

;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; Smoke tests for `testutil-fixtures'.  The fixtures exist for the upcoming
;; query/representation tests, which don't exist yet, so without this file the
;; suite would never load the fixtures and a syntax slip or shape change would
;; rot unnoticed.  These assertions exercise the file and lock the key shapes
;; the consuming tests will rely on (json-read conventions: missing keys for
;; absent fields, `t' / `:json-false' booleans).

;;; Code:

(require 'test-bootstrap (expand-file-name "test-bootstrap.el"))
(require 'testutil-fixtures (expand-file-name "testutil-fixtures.el"))

(ert-deftest test-pearl-fixture-assigned-page-shape ()
  "The assignedIssues page fixture has nodes and a pageInfo."
  (let* ((page (testutil-linear-fixture-assigned-issues-page))
         (conn (cdr (assoc 'assignedIssues
                           (assoc 'viewer (assoc 'data page))))))
    (should (= 2 (length (cdr (assoc 'nodes conn)))))
    (should (eq :json-false (cdr (assoc 'hasNextPage (assoc 'pageInfo conn)))))))

(ert-deftest test-pearl-fixture-null-fields-omits-optionals ()
  "The null-fields issue carries empty/absent project, assignee, and labels."
  (let ((issue (testutil-linear-fixture-issue-null-fields)))
    ;; present-but-empty: the key exists with a nil value (JSON null)
    (should (assoc 'project issue))
    (should (null (cdr (assoc 'project issue))))
    (should (null (cdr (assoc 'assignee issue))))
    ;; labels is an empty connection, not missing
    (should (null (cdr (assoc 'nodes (assoc 'labels issue)))))))

(ert-deftest test-pearl-fixture-custom-views-shape ()
  "The customViews fixture exposes named views with a shared flag."
  (let* ((views (cdr (assoc 'nodes (assoc 'customViews
                                          (assoc 'data (testutil-linear-fixture-custom-views)))))))
    (should (= 2 (length views)))
    (should (string-equal "My open work" (cdr (assoc 'name (car views)))))
    (should (eq t (cdr (assoc 'shared (cadr views)))))))

(ert-deftest test-pearl-fixture-comments-oldest-first ()
  "The issue-with-comments fixture orders comments oldest first."
  (let ((comments (cdr (assoc 'nodes (assoc 'comments
                                            (testutil-linear-fixture-issue-with-comments))))))
    (should (= 2 (length comments)))
    (should (string-equal "First comment" (cdr (assoc 'body (car comments)))))))

(provide 'test-pearl-fixtures)
;;; test-pearl-fixtures.el ends here