From 410e286464b7f20c9a87d52cbaa268293f20afbb Mon Sep 17 00:00:00 2001 From: Nathan Aclander Date: Sun, 14 May 2017 22:22:22 -0700 Subject: [PATCH] Added webpaste confirmation tests --- test/webpaste-test.el | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/webpaste-test.el b/test/webpaste-test.el index 056735a..7a0f0ec 100644 --- a/test/webpaste-test.el +++ b/test/webpaste-test.el @@ -63,7 +63,26 @@ ;; Test so webpaste-paste-region selects the same part of the buffer as to ;; be expected. (should (equal (webpaste-paste-region 10 100) - (buffer-substring 10 100)))))) + (buffer-substring 10 100))) + + ;; Test when wanting a paste confirmation + (let ((webpaste/paste-confirmation t)) + + ;; Override yes-or-no-p to immitate "yes" response + (cl-letf (((symbol-function 'yes-or-no-p) (lambda (text) t))) + + (should (equal (webpaste-paste-buffer) (buffer-string))) + + (should (equal (webpaste-paste-region 10 100) + (buffer-substring 10 100)))) + + ;; Override yes-or-no-p to immitate "no" response + (cl-letf (((symbol-function 'yes-or-no-p) (lambda (text) nil))) + + (should (not (equal (webpaste-paste-buffer) (buffer-string)))) + + (should (not (equal (webpaste-paste-region 10 100) + (buffer-substring 10 100)))))))))