From 5a067b8d3a0d7ffd50d430d0b072450b4ee952f6 Mon Sep 17 00:00:00 2001 From: Joao Tavora Date: Sun, 20 Oct 2013 12:45:23 +0100 Subject: [PATCH] add: tests for clearing unmodified fields --- snippet-tests.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/snippet-tests.el b/snippet-tests.el index 3c09069..f81d426 100644 --- a/snippet-tests.el +++ b/snippet-tests.el @@ -54,8 +54,7 @@ (defun snippet--insert-test-snippet (name) (funcall (make-snippet (cadr (assoc name snippet--test-snippets-alist))))) - -(ert-deftest foo-expansion () +(ert-deftest basic-expansion () (with-temp-buffer (snippet--insert-test-snippet 'basic) (should (equal (buffer-string) "foo bar foo")) @@ -63,6 +62,19 @@ (overlay-end snippet--field-overlay)) "foo" )))) +(ert-deftest basic-clear-field () + (with-temp-buffer + (snippet--insert-test-snippet 'basic) + (ert-simulate-command '((lambda () (interactive) (insert "baz")))) + (should (equal (buffer-string) "baz bar baz")))) + +(ert-deftest basic-delete-char-in-field () + (with-temp-buffer + (snippet--insert-test-snippet 'basic) + (ert-simulate-command '(delete-forward-char 1)) + (ert-simulate-command '((lambda () (interactive) (insert "b")))) + (should (equal (buffer-string) "boo bar boo")))) + (ert-deftest contrived () (with-temp-buffer (snippet--insert-test-snippet 'contrived) @@ -87,6 +99,7 @@ (ert-simulate-command '((lambda () (interactive) (insert "foo")))) (should (equal (buffer-string) "foobarbaz")))) + (ert-deftest printf-expansion () (with-temp-buffer (snippet--insert-test-snippet 'printf)