summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLuka Hadzi-Djokic <luka.hadzi@proton.me>2023-09-12 10:33:06 +0200
committerLuka Hadzi-Djokic <luka.hadzi@proton.me>2023-09-13 13:38:45 +0200
commit3f9da18586fea56a5a9301732d02e58cf8a5c0f3 (patch)
tree54e91b1e4b3bef23f795bd2044e63f1f42c4f3b6 /tests
parentdeaab73f8c9d8dbf209b2dcd9540c4f65e8d64b5 (diff)
Allow for overwriting slots with repeated `define-configuration`.
Add `:append t` to the `hooks:add-hook` call in `define-configuration`, so that the hooks are evaluated in the correct order. Clean up the `define-configuration` tests and add a test for this behavior.
Diffstat (limited to 'tests')
-rw-r--r--tests/offline/define-configuration.lisp45
1 files changed, 26 insertions, 19 deletions
diff --git a/tests/offline/define-configuration.lisp b/tests/offline/define-configuration.lisp
index 59e3faa16..402adcc6e 100644
--- a/tests/offline/define-configuration.lisp
+++ b/tests/offline/define-configuration.lisp
@@ -7,32 +7,40 @@
(let ((test-url (quri:uri "about:blank")))
(nyxt:define-configuration nyxt:browser
((nyxt:default-new-buffer-url test-url)))
- (let ((browser (make-instance 'browser)))
- (assert-equality #'quri:uri=
- test-url
- (nyxt:default-new-buffer-url browser)))
+ (assert-equality #'quri:uri=
+ test-url
+ (nyxt:default-new-buffer-url (make-instance 'browser)))
(nyxt:clean-configuration)
- (let ((browser (make-instance 'browser)))
- (assert-equality #'quri:uri=
- (quri:uri (nyxt-url 'new))
- (nyxt:default-new-buffer-url browser)))
+ (assert-equality #'quri:uri=
+ (quri:uri (nyxt-url 'new))
+ (nyxt:default-new-buffer-url (make-instance 'browser)))
+ (nyxt:clean-configuration)))
+
+(define-test overwritten-configuration ()
+ (let ((test-first-url (quri:uri "https://example.com/first"))
+ (test-second-url (quri:uri "https://example.com/second")))
+ (nyxt:define-configuration nyxt:browser
+ ((nyxt:default-new-buffer-url test-first-url)))
+ (nyxt:define-configuration nyxt:browser
+ ((nyxt:default-new-buffer-url test-second-url)))
+ (assert-equality #'quri:uri=
+ test-second-url
+ (nyxt:default-new-buffer-url (make-instance 'browser)))
(nyxt:clean-configuration)))
(define-test slot-default ()
(let ((test-url (quri:uri "about:blank")))
(nyxt:define-configuration nyxt:browser
((nyxt:default-new-buffer-url test-url)))
- (let ((browser (make-instance 'browser)))
- (assert-equality #'quri:uri=
- test-url
- (nyxt:default-new-buffer-url browser)))
+ (assert-equality #'quri:uri=
+ test-url
+ (nyxt:default-new-buffer-url (make-instance 'browser)))
(nyxt:clean-configuration)
(nyxt:define-configuration nyxt:browser
((nyxt:default-new-buffer-url nyxt:%slot-default%)))
- (let ((browser (make-instance 'browser)))
- (assert-equality #'quri:uri=
- (quri:uri (nyxt-url 'new))
- (nyxt:default-new-buffer-url browser)))
+ (assert-equality #'quri:uri=
+ (quri:uri (nyxt-url 'new))
+ (nyxt:default-new-buffer-url (make-instance 'browser)))
(nyxt:clean-configuration)))
(define-test test-slot-value ()
@@ -46,6 +54,5 @@
(make-instance 'hooks:handler
:fn (lambda () (print 'dummy2))
:name 'dummy2)))))
- (let ((browser (make-instance 'browser)))
- (assert-eql 2
- (length (hooks:handlers (nyxt:before-exit-hook browser))))))
+ (assert-eql 2
+ (length (hooks:handlers (nyxt:before-exit-hook (make-instance 'browser))))))