test-ido-completing-read+.el 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. ;;; -*- lexical-binding: t -*-
  2. (require 'ido-completing-read+)
  3. (require 'buttercup)
  4. (require 'cl-lib)
  5. (require 'with-simulated-input)
  6. (defun collection-as-function (collection)
  7. "Return a function equivalent to COLLECTION.
  8. The returned function will work equivalently to COLLECTION when
  9. passed to `all-completions' and `try-completion'."
  10. (completion-table-dynamic (lambda (string) (all-completions string collection))))
  11. (defun ido-cr+-test-save-custom-vars (vars)
  12. (cl-loop
  13. for var in vars
  14. if (not (custom-variable-p var))
  15. do (error "Variable `%s' is not a customizable variable" var)
  16. for curval = (symbol-value var)
  17. for stdval = (eval (car (get var 'standard-value)))
  18. for setter = (or (get var 'custom-set) 'set-default)
  19. do
  20. (progn
  21. ;; Save the current value
  22. (put var 'ido-cr+-test-saved-value curval)
  23. ;; Set it to the standard value, using it's custom setter
  24. ;; function
  25. (funcall setter var stdval))))
  26. (defun ido-cr+-test-restore-custom-vars (vars)
  27. (cl-loop
  28. for var in vars
  29. for savedval = (get var 'ido-cr+-test-saved-value)
  30. for setter = (or (get var 'custom-set) 'set-default)
  31. do
  32. (progn
  33. ;; Set it to the saved value, using it's custom setter function
  34. (funcall setter var savedval)
  35. ;; Delete the saved value from the symbol plist
  36. (put var 'ido-cr+-test-saved-value nil))))
  37. (describe "Within the `ido-completing-read+' package"
  38. ;; All these need to be saved before and restored after each each test
  39. :var (ido-mode
  40. ido-ubiquitous-mode
  41. ido-cr+-debug-mode
  42. ido-cr+-auto-update-blacklist
  43. ido-cr+-fallback-function
  44. ido-cr+-max-items
  45. ido-cr+-function-blacklist
  46. ido-cr+-function-whitelist
  47. ido-cr+-replace-completely
  48. ido-confirm-unique-completion
  49. ido-enable-flex-matching)
  50. ;; Reset all of these variables to their standard values before each
  51. ;; test
  52. (before-each
  53. (ido-cr+-test-save-custom-vars
  54. '(ido-mode
  55. ido-ubiquitous-mode
  56. ido-cr+-debug-mode
  57. ido-cr+-auto-update-blacklist
  58. ido-cr+-fallback-function
  59. ido-cr+-max-items
  60. ido-cr+-function-blacklist
  61. ido-cr+-function-whitelist
  62. ido-cr+-replace-completely
  63. ido-confirm-unique-completion
  64. ido-enable-flex-matching))
  65. ;; Now enable ido-mode and ido-ubiquitous-mode
  66. (ido-mode 1)
  67. (ido-ubiquitous-mode 1))
  68. ;; Restore the saved value after each test
  69. (after-each
  70. (ido-cr+-test-restore-custom-vars
  71. '(ido-mode
  72. ido-ubiquitous-mode
  73. ido-cr+-debug-mode
  74. ido-cr+-auto-update-blacklist
  75. ido-cr+-fallback-function
  76. ido-cr+-max-i
  77. tems
  78. ido-cr+-function-blacklist
  79. ido-cr+-function-whitelist
  80. ido-cr+-replace-completely
  81. ido-confirm-unique-completion
  82. ido-enable-flex-matching)))
  83. (describe "the `ido-completing-read+' function"
  84. (it "should complete with a matching item on RET"
  85. (expect
  86. (with-simulated-input "g RET"
  87. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
  88. :to-equal "green"))
  89. (it "should complete with the first match when multiple matches are available"
  90. (expect
  91. (with-simulated-input "b RET"
  92. (ido-completing-read+ "Prompt: " '("brown" "blue" "yellow" "green")))
  93. :to-equal "brown"))
  94. (it "should allow <left> and <right> to cycle completions, with wrap-around"
  95. (expect
  96. (with-simulated-input "b <right> <right> <right> <right> <left> RET"
  97. (ido-completing-read+ "Prompt: " '("brown" "blue" "yellow" "green")))
  98. :to-equal
  99. "blue"))
  100. (it "should return \"\" when RET or C-j is pressed on an empty input even when REQUIRE-MATCH is non-nil"
  101. ;; No REQUIRE-MATCH
  102. (expect
  103. (with-simulated-input "RET"
  104. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
  105. :to-equal "blue")
  106. (expect
  107. (with-simulated-input "C-j"
  108. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
  109. :to-equal "")
  110. ;; Again, with REQUIRE-MATCH
  111. (expect
  112. (with-simulated-input "RET"
  113. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil t))
  114. :to-equal "")
  115. (expect
  116. (with-simulated-input "C-j"
  117. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil t))
  118. :to-equal ""))
  119. ;; Verify that DEF works, whether or not it is an element of
  120. ;; COLLECTION
  121. (it "should accept all the same forms of DEF as `completing-read-default'"
  122. (expect
  123. (with-simulated-input "RET"
  124. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil nil nil "green"))
  125. :to-equal "green")
  126. (expect
  127. (with-simulated-input "RET"
  128. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil t nil nil "green"))
  129. :to-equal "green")
  130. (expect
  131. (with-simulated-input "RET"
  132. (ido-completing-read+ "Prompt: " '("blue" "yellow" "brown") nil nil nil nil "brown"))
  133. :to-equal "brown")
  134. (expect
  135. (with-simulated-input "RET"
  136. (ido-completing-read+ "Prompt: " '("blue" "yellow" "brown") nil t nil nil "brown"))
  137. :to-equal "brown")
  138. (expect
  139. (with-simulated-input "RET"
  140. (ido-completing-read+ "Prompt: " '("blue" "yellow" "brown") nil t nil nil '("brown" "green")))
  141. :to-equal "brown"))
  142. ;; Verify that INITIAL-INPUT works
  143. (it "should work with INITIAL-INPUT"
  144. (expect
  145. (with-simulated-input "RET"
  146. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil "gr"))
  147. :to-equal "green"))
  148. ;; Verify that INITIAL-INPUT and DEF don't interfere with each other
  149. (it "should properly handle both INITIAL-INPUT and DEF at the same time"
  150. (expect
  151. (with-simulated-input "RET"
  152. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil "gr" nil "blue"))
  153. :to-equal "green")
  154. (expect
  155. (with-simulated-input "DEL DEL RET"
  156. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green") nil nil "gr" nil "blue"))
  157. :to-equal "blue"))
  158. ;; Verify that ido-cr+ works on function collections
  159. (it "should work when COLLECTION is a function"
  160. (expect
  161. (with-simulated-input "g RET"
  162. (ido-completing-read+ "Prompt: " (collection-as-function '("blue" "yellow" "green"))))
  163. :to-equal "green"))
  164. (describe "when `ido-cr+-max-items' is set"
  165. (it "should not trigger a fallback for small collections"
  166. (expect
  167. (with-simulated-input "g RET"
  168. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
  169. :to-equal "green"))
  170. (it "should trigger a fallback for large collections"
  171. (expect
  172. ;; With max-items negative, all collections are considered "too
  173. ;; large"
  174. (let ((ido-cr+-max-items -1))
  175. (with-simulated-input "g RET"
  176. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green"))))
  177. :to-equal "g")))
  178. (describe "when REQUIRE-MATCH is non-nil"
  179. (it "should still allow exiting with an empty string if DEF is nil"
  180. (expect
  181. (with-simulated-input "C-j"
  182. (ido-completing-read+
  183. "Prompt: "
  184. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))
  185. :to-equal ""))
  186. ;; "C-j" should NOT be allowed to return an empty string if
  187. ;; require-match and default are both non-nil.
  188. (it "should not alow exiting with an empty string if DEF is non-nil"
  189. (expect
  190. (lambda ()
  191. (with-simulated-input "C-j"
  192. (ido-completing-read+
  193. "Prompt: "
  194. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t nil nil "yellow")))
  195. :to-throw))
  196. (it "shouldn't allow C-j to select an ambiguous match"
  197. (expect
  198. (lambda ()
  199. (with-simulated-input "b C-j C-j C-j"
  200. (ido-completing-read+
  201. "Prompt: "
  202. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
  203. :to-throw)
  204. ;; First press of C-j should complete to "blue" after the
  205. ;; first b, but then get stuck on the choice for the second b.
  206. (expect
  207. (lambda ()
  208. (with-simulated-input "b C-j b C-j C-j"
  209. (ido-completing-read+
  210. "Prompt: "
  211. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
  212. :to-throw))
  213. (it "should allow exiting with an unambiguous match"
  214. (expect
  215. (with-simulated-input "b C-j b C-j e C-j C-j"
  216. (ido-completing-read+
  217. "Prompt: "
  218. '("bluebird" "blues" "bluegrass" "blueberry" "yellow" "green") nil t))
  219. :to-equal "blueberry")
  220. ;; The "C-j" should complete to "bluegrass" and return, because
  221. ;; `ido-confirm-unique-completion is nil.
  222. (expect
  223. (with-simulated-input "b l u e g C-j"
  224. (ido-completing-read+
  225. "Prompt: "
  226. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))
  227. :to-equal "bluegrass"))
  228. (it "should require an extra C-j to exit when `ido-confirm-unique-completion' is non-nil"
  229. (setq ido-confirm-unique-completion t)
  230. ;; Now the first "C-j" should complete to "bluegrass" but should
  231. ;; not return.
  232. (expect
  233. (lambda ()
  234. (with-simulated-input "b l u e g C-j"
  235. (ido-completing-read+
  236. "Prompt: "
  237. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t)))
  238. :to-throw)
  239. ;; The first "C-j" should complete to "bluegrass", and the second
  240. ;; should return.
  241. (expect
  242. (with-simulated-input "b l u e g C-j C-j"
  243. (ido-completing-read+
  244. "Prompt: "
  245. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))
  246. :to-equal "bluegrass"))
  247. ;; Finally, a test for the expected wrong behavior without
  248. ;; ido-cr+. If ido.el ever fixes this bug, it will cause this test
  249. ;; to fail as a signal that the workaround can be phased out.
  250. (it "should return a non-match when ordinary `ido-completing-read' is used"
  251. (expect
  252. (with-simulated-input "b C-j"
  253. (ido-completing-read
  254. "Prompt: "
  255. '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))
  256. :to-equal "b")))
  257. (describe "with manual fallback shortcuts"
  258. (it "should not fall back when C-b or C-f is used in the middle of the input"
  259. (expect
  260. ;; C-b/f not at beginning/end of input should not fall back
  261. (with-simulated-input "g C-b C-f RET"
  262. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
  263. :to-equal "green"))
  264. (it "should fall back on C-f at end of input"
  265. (expect
  266. ;; C-f at end of input should fall back
  267. (with-simulated-input "g C-f RET"
  268. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
  269. :to-equal "g"))
  270. (it "should not fall back from repeated C-b that hits the start of input"
  271. (expect
  272. ;; Repeated C-b should not fall back
  273. (with-simulated-input "g C-b C-b C-b C-b RET"
  274. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
  275. :to-equal "green"))
  276. (it "should fall back on C-b at beginning of input (if previous action was not C-b)"
  277. (expect
  278. ;; C-b at beginning of line should fall back (if previous action
  279. ;; was not also C-b)
  280. (with-simulated-input "g C-b x DEL C-b RET"
  281. (ido-completing-read+ "Prompt: " '("blue" "yellow" "green")))
  282. :to-equal "g")))
  283. (describe "with a work workaround for an bug with `ido-enable-dot-prefix'"
  284. ;; See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26997
  285. ;; for more information on this bug.
  286. (before-each
  287. (setq ido-enable-dot-prefix t))
  288. (it "should not throw an error when `ido-enable-dot-prefix' is non-nil and \"\" is in the collection"
  289. (expect
  290. (with-simulated-input "RET"
  291. (ido-completing-read+ "Pick: " '("" "aaa" "aab" "aac")))
  292. :to-equal "")
  293. (expect
  294. (with-simulated-input "a a b RET"
  295. (ido-completing-read+ "Pick: " '("" "aaa" "aab" "aac")))
  296. :to-equal "aab")))
  297. (describe "with dynamic collections"
  298. (before-all
  299. (setq my-dynamic-collection
  300. (completion-table-dynamic
  301. (lambda (text)
  302. (cond
  303. ;; Sub-completions for "hello"
  304. ((s-prefix-p "hello" text)
  305. '("hello" "hello-world" "hello-everyone" "hello-universe"))
  306. ;; Sub-completions for "goodbye"
  307. ((s-prefix-p "goodbye" text)
  308. '("goodbye" "goodbye-world" "goodbye-everyone" "goodbye-universe"))
  309. ;; General completions
  310. (t
  311. '("hello" "goodbye" "helicopter" "helium" "goodness" "goodwill")))))))
  312. (after-all
  313. (setq my-dynamic-collection nil))
  314. (before-each
  315. (setq ido-enable-flex-matching t
  316. ido-confirm-unique-completion nil)
  317. (spy-on 'ido-cr+-update-dynamic-collection
  318. :and-call-through))
  319. (it "should allow selection of dynamically-added completions"
  320. (expect
  321. (with-simulated-input "hello- RET"
  322. (ido-completing-read+ "Say something: " my-dynamic-collection))
  323. :to-equal "hello-world")
  324. (expect 'ido-cr+-update-dynamic-collection
  325. :to-have-been-called))
  326. (it "should allow ido flex-matching of dynamically-added completions"
  327. (expect
  328. (with-simulated-input "hello-ld RET"
  329. (ido-completing-read+ "Say something: " my-dynamic-collection))
  330. :to-equal
  331. "hello-world")
  332. (expect 'ido-cr+-update-dynamic-collection
  333. :to-have-been-called))
  334. (it "should do a dynamic update when pressing TAB"
  335. (expect
  336. (with-simulated-input "h TAB -ld RET"
  337. (ido-completing-read+ "Say something: " my-dynamic-collection))
  338. :to-equal
  339. "hello-world")
  340. (expect 'ido-cr+-update-dynamic-collection
  341. :to-have-been-called))
  342. (it "should do a dynamic update when idle"
  343. (expect
  344. (with-simulated-input
  345. '("h"
  346. (wsi-simulate-idle-time (1+ ido-cr+-dynamic-update-idle-time))
  347. "-ld RET")
  348. (ido-completing-read+ "Say something: " my-dynamic-collection))
  349. :to-equal
  350. "hello-world")
  351. (expect 'ido-cr+-update-dynamic-collection
  352. :to-have-been-called))
  353. (it "should do a dynamic update when there is only one match remaining"
  354. (expect
  355. (with-simulated-input "hell-ld RET"
  356. (ido-completing-read+ "Say something: " my-dynamic-collection))
  357. :to-equal
  358. "hello-world")
  359. (expect 'ido-cr+-update-dynamic-collection
  360. :to-have-been-called))
  361. (it "should not exit with a unique match if new matches are dynamically added"
  362. (expect
  363. (with-simulated-input '("hell TAB -ld RET")
  364. (ido-completing-read+ "Say something: " my-dynamic-collection))
  365. :to-equal
  366. "hello-world")
  367. (expect 'ido-cr+-update-dynamic-collection
  368. :to-have-been-called))
  369. (it "should exit with a match that is still unique after dynamic updating"
  370. (expect
  371. (with-simulated-input '("helic TAB")
  372. (ido-completing-read+ "Say something: " my-dynamic-collection))
  373. :to-equal
  374. "helicopter")
  375. (expect 'ido-cr+-update-dynamic-collection
  376. :to-have-been-called))))
  377. (describe "ido-ubiquitous-mode"
  378. ;; Set up a test command that calls `completing-read'
  379. (before-all
  380. (setf (symbol-function 'test-command)
  381. (lambda ()
  382. (interactive)
  383. (completing-read "Prompt: " '("blue" "yellow" "green")))))
  384. ;; Delete the test command
  385. (after-all
  386. (setf (symbol-function 'test-command) nil))
  387. ;; Verify that the mode can be activated
  388. (it "should enable itself properly"
  389. (expect
  390. (progn
  391. (ido-ubiquitous-mode 1)
  392. (with-simulated-input "g RET"
  393. (command-execute 'test-command)))
  394. :to-equal "green"))
  395. (it "should disable itself properly"
  396. (expect
  397. (progn
  398. (ido-ubiquitous-mode 0)
  399. (with-simulated-input "g RET"
  400. (command-execute 'test-command)))
  401. :to-equal "g"))
  402. (describe "with `ido-cr+-function-blacklist'"
  403. (before-all
  404. (setf (symbol-function 'blacklisted-command)
  405. (lambda (arg)
  406. (interactive (list (completing-read "Prompt: " '("blue" "yellow" "green"))))
  407. arg)
  408. (symbol-function 'blacklisted-function)
  409. (lambda ()
  410. (completing-read "Prompt: " '("blue" "yellow" "green")))
  411. (symbol-function 'cmd-that-calls-blacklisted-function)
  412. (lambda ()
  413. (interactive)
  414. (funcall 'blacklisted-function))
  415. (symbol-function 'blacklisted-collection)
  416. (collection-as-function '("blue" "yellow" "green"))))
  417. (after-all
  418. (setf (symbol-function 'blacklisted-command) nil
  419. (symbol-function 'blacklisted-function) nil
  420. (symbol-function 'cmd-that-calls-blacklisted-function) nil
  421. (symbol-function 'blacklisted-collection) nil))
  422. ;; First verify that they work normally before blacklisting them
  423. (describe "when the blacklist is empty"
  424. (it "should not affect a non-blacklisted command"
  425. (expect
  426. (with-simulated-input "g RET"
  427. (call-interactively 'blacklisted-command))
  428. :to-equal "green"))
  429. (it "should not affect a non-blacklisted function"
  430. (expect
  431. (with-simulated-input "g RET"
  432. (call-interactively 'cmd-that-calls-blacklisted-function))
  433. :to-equal "green"))
  434. (it "should not affect a non-blacklisted collection"
  435. (expect
  436. (with-simulated-input "g RET"
  437. (ido-completing-read+ "Prompt: " 'blacklisted-collection))
  438. :to-equal "green")))
  439. (describe "when the specified functions are blacklisted"
  440. (before-each
  441. (setq ido-cr+-function-blacklist
  442. (append '(blacklisted-command
  443. blacklisted-function
  444. blacklisted-collection)
  445. ido-cr+-function-blacklist)))
  446. (it "should prevent ido in a blacklisted command"
  447. (expect
  448. (with-simulated-input "g RET"
  449. (call-interactively 'blacklisted-command))
  450. :to-equal "g"))
  451. (it "should prevent ido in a blacklisted function"
  452. (expect
  453. (with-simulated-input "g RET"
  454. (call-interactively 'cmd-that-calls-blacklisted-function))
  455. :to-equal "g"))
  456. (it "should prevent ido with a blacklisted collection"
  457. (expect
  458. (with-simulated-input "g RET"
  459. (ido-completing-read+ "Prompt: " 'blacklisted-collection))
  460. :to-equal "g"))))
  461. (describe "with `ido-cr+-function-whitelist'"
  462. (before-all
  463. (setf (symbol-function 'whitelisted-command)
  464. (lambda (arg)
  465. (interactive
  466. (list
  467. (completing-read "Prompt: " '("blue" "yellow" "green"))))
  468. arg)
  469. (symbol-function 'whitelisted-function)
  470. (lambda ()
  471. (completing-read "Prompt: " '("blue" "yellow" "green")))
  472. (symbol-function 'cmd-that-calls-whitelisted-function)
  473. (lambda ()
  474. (interactive)
  475. (funcall 'whitelisted-function))
  476. (symbol-function 'whitelisted-collection)
  477. (lambda (string pred action)
  478. (complete-with-action action '("blue" "yellow" "green") string pred))))
  479. (after-all
  480. (setf (symbol-function 'whitelisted-command) nil
  481. (symbol-function 'whitelisted-function) nil
  482. (symbol-function 'cmd-that-calls-whitelisted-function) nil
  483. (symbol-function 'whitelisted-collection) nil))
  484. (describe "when the whitelist is inactive (i.e. everything is whitelisted)"
  485. (before-each
  486. (setq ido-cr+-function-whitelist nil))
  487. (it "should enable ido in a command"
  488. (expect
  489. (with-simulated-input "g RET"
  490. (call-interactively 'whitelisted-command))
  491. :to-equal "green"))
  492. (it "should enable ido in a function"
  493. (expect
  494. (with-simulated-input "g RET"
  495. (call-interactively 'cmd-that-calls-whitelisted-function))
  496. :to-equal "green"))
  497. (it "should enable ido for a collection"
  498. (expect
  499. (with-simulated-input "g RET"
  500. (ido-completing-read+ "Prompt: " 'whitelisted-collection))
  501. :to-equal "green")))
  502. (describe "when the specified functions are whitelisted"
  503. (before-each
  504. (setq ido-cr+-function-whitelist
  505. (append '(whitelisted-command
  506. whitelisted-function
  507. whitelisted-collection)
  508. ido-cr+-function-whitelist)))
  509. (it "should enable ido in a whitelisted command"
  510. (expect
  511. (with-simulated-input "g RET"
  512. (call-interactively 'whitelisted-command))
  513. :to-equal "green"))
  514. (it "should enable ido in a whitelisted function"
  515. (expect
  516. (with-simulated-input "g RET"
  517. (call-interactively 'cmd-that-calls-whitelisted-function))
  518. :to-equal "green"))
  519. (it "should enable ido for a whitelisted collection"
  520. (expect
  521. (with-simulated-input "g RET"
  522. (ido-completing-read+ "Prompt: " 'whitelisted-collection))
  523. :to-equal "green")))
  524. (describe "when the whitelist is active but empty (i.e. nothing whitelisted)"
  525. (before-each
  526. (setq ido-cr+-function-whitelist (list nil)))
  527. (it "should prevent ido in a command"
  528. (expect
  529. (with-simulated-input "g RET"
  530. (call-interactively 'whitelisted-command))
  531. :to-equal "g"))
  532. (it "should prevent ido in a function"
  533. (expect
  534. (with-simulated-input "g RET"
  535. (call-interactively 'cmd-that-calls-whitelisted-function))
  536. :to-equal "g"))
  537. (it "should prevent ido for a collection"
  538. (expect
  539. (with-simulated-input "g RET"
  540. (ido-completing-read+ "Prompt: " 'whitelisted-collection))
  541. :to-equal "g"))))))
  542. ;; (defun ido-cr+-run-all-tests ()
  543. ;; (interactive)
  544. ;; (ert "^ido-cr\\+-"))
  545. ;;; test-ido-completing-read+.el ends here