2018-06-15 03:31:54 +02:00
|
|
|
|
;; -*- no-byte-compile: t; -*-
|
|
|
|
|
;;; core/test/test-autoload-message.el
|
|
|
|
|
|
2019-09-03 00:41:03 -04:00
|
|
|
|
(describe "core/autoload/format"
|
2018-06-15 03:31:54 +02:00
|
|
|
|
(describe "format!"
|
2020-05-25 03:32:50 -04:00
|
|
|
|
:var (doom-output-backend)
|
2019-04-23 12:41:46 -04:00
|
|
|
|
(before-all
|
2020-05-25 03:32:50 -04:00
|
|
|
|
(setq doom-output-backend 'ansi))
|
2018-06-15 03:31:54 +02:00
|
|
|
|
|
|
|
|
|
(it "should be a drop-in replacement for `format'"
|
|
|
|
|
(expect (format! "Hello %s" "World")
|
|
|
|
|
:to-equal "Hello World"))
|
|
|
|
|
|
|
|
|
|
(it "supports ansi coloring in noninteractive sessions"
|
2018-09-07 21:56:07 -04:00
|
|
|
|
(expect (format! (red "Hello %s") "World")
|
2018-06-15 03:31:54 +02:00
|
|
|
|
:to-equal "[31mHello World[0m"))
|
|
|
|
|
|
2019-04-23 12:41:46 -04:00
|
|
|
|
(it "supports text properties in interactive sessions"
|
2020-05-25 03:32:50 -04:00
|
|
|
|
(let ((doom-output-backend 'text-properties))
|
2018-09-07 21:56:07 -04:00
|
|
|
|
(expect (get-text-property 0 'face (format! (red "Hello %s") "World"))
|
2018-06-15 03:31:54 +02:00
|
|
|
|
:to-equal (list :foreground (face-foreground 'term-color-red)))))
|
|
|
|
|
|
|
|
|
|
(it "supports nested color specs"
|
2018-09-07 21:56:07 -04:00
|
|
|
|
(expect (format! (bold (red "Hello %s")) "World")
|
2018-06-15 03:31:54 +02:00
|
|
|
|
:to-equal (format "\e[%dm%s\e[0m" 1
|
|
|
|
|
(format "\e[%dm%s\e[0m" 31 "Hello World")))
|
2018-09-07 21:56:07 -04:00
|
|
|
|
(expect (format! (on-red (bold "Hello %s")) "World")
|
2018-06-15 03:31:54 +02:00
|
|
|
|
:to-equal (format "\e[%dm%s\e[0m" 41
|
|
|
|
|
(format "\e[%dm%s\e[0m" 1 "Hello World")))
|
2018-09-07 21:56:07 -04:00
|
|
|
|
(expect (format! (dark (white "Hello %s")) "World")
|
2018-06-15 03:31:54 +02:00
|
|
|
|
:to-equal (format "\e[%dm%s\e[0m" 2
|
|
|
|
|
(format "\e[%dm%s\e[0m" 37 "Hello World"))))
|
|
|
|
|
|
|
|
|
|
(it "supports dynamic color apply syntax"
|
2018-09-07 21:56:07 -04:00
|
|
|
|
(expect (format! (color 'red "Hello %s") "World")
|
|
|
|
|
:to-equal (format! (red "Hello %s") "World"))
|
|
|
|
|
(expect (format! (color (if nil 'red 'blue) "Hello %s") "World")
|
2019-09-03 00:41:03 -04:00
|
|
|
|
:to-equal (format! (blue "Hello %s") "World"))))
|
|
|
|
|
|
|
|
|
|
(xdescribe "insert!")
|
|
|
|
|
(xdescribe "print!")
|
|
|
|
|
(xdescribe "print-group!")
|
|
|
|
|
(xdescribe "error!")
|
|
|
|
|
(xdescribe "user-error!"))
|