js-tests.el 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ;;; js-tests.el --- Test suite for js-mode
  2. ;; Copyright (C) 2017 Free Software Foundation, Inc.
  3. ;; This file is part of GNU Emacs.
  4. ;; GNU Emacs is free software: you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;; GNU Emacs is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;; You should have received a copy of the GNU General Public License
  13. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  14. ;;; Commentary:
  15. ;;; Code:
  16. (require 'ert)
  17. (require 'js)
  18. (ert-deftest js-mode-fill-bug-19399 ()
  19. (with-temp-buffer
  20. (insert "/")
  21. (save-excursion (insert "/ comment"))
  22. (js-mode)
  23. (fill-paragraph)
  24. (should (equal (buffer-substring (point-min) (point-max))
  25. "// comment"))))
  26. (ert-deftest js-mode-fill-bug-22431 ()
  27. (with-temp-buffer
  28. (insert "/**\n")
  29. (insert " * Load the inspector's shared head.js for use by tests that ")
  30. (insert "need to open the something or other")
  31. (js-mode)
  32. ;; This fails with auto-fill but not fill-paragraph.
  33. (do-auto-fill)
  34. (should (equal (buffer-substring (point-min) (point-max))
  35. "/**
  36. * Load the inspector's shared head.js for use by tests that need to
  37. * open the something or other"))))
  38. (ert-deftest js-mode-fill-bug-22431-fill-paragraph-at-start ()
  39. (with-temp-buffer
  40. (insert "/**\n")
  41. (insert " * Load the inspector's shared head.js for use by tests that ")
  42. (insert "need to open the something or other")
  43. (js-mode)
  44. (goto-char (point-min))
  45. (fill-paragraph)
  46. (should (equal (buffer-substring (point-min) (point-max))
  47. "/**
  48. * Load the inspector's shared head.js for use by tests that need to
  49. * open the something or other"))))
  50. (provide 'js-tests)
  51. ;;; js-tests.el ends here