aboutsummaryrefslogtreecommitdiff
path: root/tests/test-init-defer-games.el
blob: 0b85a1ea7fd0db0c78656b9b53a20ff4f090b70f (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
;;; test-init-defer-games.el --- games-config Phase 4 deferral -*- lexical-binding: t; -*-

;;; Commentary:
;; games-config is deferred (load-graph Phase 4): init.el autoloads `malyon'
;; and `2048-game' instead of requiring the module eagerly.  These tests guard
;; that the game commands stay reachable with the module unloaded, and that
;; loading the module still applies the one setting it owns.

;;; Code:

(require 'ert)
(require 'package)

(ert-deftest test-init-defer-games-commands-autoload-without-module ()
  "Normal: the game commands resolve with games-config unloaded.
This is the safety net for the deferral -- dropping the eager require keeps
malyon and 2048-game reachable only because the packages autoload their own
commands, so assert that holds."
  (package-initialize)
  (should-not (featurep 'games-config))
  (should (commandp 'malyon))
  (should (commandp '2048-game)))

(ert-deftest test-init-defer-games-config-applies-malyon-stories-dir ()
  "Normal: loading games-config still applies malyon's stories directory.
The module is the config owner; deferring it must not drop the one setting it
adds (`malyon-stories-directory'), which use-package applies when malyon loads."
  (package-initialize)
  (add-to-list 'load-path (expand-file-name "modules" default-directory))
  (require 'user-constants)
  (let ((org-dir "/tmp/games-defer-test/"))
    (load "games-config" nil t)
    (unless (require 'malyon nil t)
      (ert-skip "malyon package not available"))
    (should (equal malyon-stories-directory "/tmp/games-defer-test/text.games/"))))

(provide 'test-init-defer-games)
;;; test-init-defer-games.el ends here