{"action":"created","comment":{"url":"https://api.github.com/repos/bevacqua/banksy/pulls/comments/72797197","id":72797197,"diff_hunk":"@@ -1,42 +1,280 @@\n-var editor;\n+var editor, el, horse, bridge;\n \n describe(\"Banksy\", function() {\n \n   beforeAll(function() {\n \n-    editor = woofmark($('#woofmark')[0], {\n+    el = $('#woofmark')[0];\n+\n+    editor = woofmark(el, {\n       parseMarkdown: megamark,\n       parseHTML:     domador\n     });\n \n-  });\n-\n-\n-  it(\"initializes\", function() {\n-\n-    var horse = horsey(editor.editable, {\n+    horse = horsey(el, {\n       anchor: '@',\n       suggestions: [\n-        '@hodor'\n-        //{ value: '@hodor',  text: 'Hodor'   },\n+        { value: '@hodor',  text: 'Hodor' }\n       ],\n       set: function (value) {\n         if (wysiwyg.mode === 'wysiwyg') {\n-          editor.textarea.innerHTML = value;\n+          editor.editable.innerHTML = value;\n         } else {\n           editor.textarea.value = value;\n         }\n       }\n     });\n \n-    var bridge = banksy(editor.textarea, {\n+    bridge = banksy(el, {\n       editor: editor,\n       horse: horse\n     });\n \n+    enter = function(before, after) {\n+\n+      before = before || \"\";\n+      after  = after  || \"\";\n+\n+      editor.runCommand(function(chunks, mode) {\n+        chunks.before = chunks.before + before;\n+        chunks.after = after + chunks.after;\n+      });\n+ \n+      // trigger the horsey:\n+      crossvent.fabricate(el, \"keypress\");\n+\n+    }\n+\n+  });\n+\n+\n+  it(\"initializes\", function() {\n+\n     expect($('.sey-list')).not.toBe(null);\n+    expect($('.sey-list .sey-item').html()).toBe(\"Hodor\");\n+\n+  });\n+\n+\n+  it(\"displays on @ token entry\", function(done) {\n+\n+    editor.value('');\n+    editor.setMode('wysiwyg');\n+\n+    enter('hello');\n+    expect($('.sey-list .sey-item:first').is(':visible')).toBe(false);\n+\n+    function onShow() {\n+\n+      expect($('.sey-list .sey-item:first').is(':visible')).toBe(true);\n+      expect(editor.value()).toEqual('hello @');\n+\n+      crossvent.remove(editor.editable, 'horsey-show', onShow);\n+\n+      done();\n+\n+    }\n+\n+    enter(' @');\n+\n+    crossvent.add(editor.editable, 'horsey-show', onShow);\n+\n+  });\n+\n+\n+  it(\"autocompletes on selection click in wysiwyg mode\", function(done) {\n+\n+    editor.setMode('wysiwyg');\n+    editor.value('');\n+\n+    function onHide() {\n+\n+      expect($('.sey-list .sey-item:first').is(':visible')).toBe(false);\n+\n+      crossvent.add(editor.editable, 'horsey-show', onShow);\n+\n+      enter(' @');\n+\n+    }\n+ \n+    function onShow() {\n+\n+      // Somehow, dropping priority gives time for this to run; \n+      // possibly for the element to appear and/or move?\n+      setTimeout(function() {\n+\n+        expect($('.sey-list .sey-item:first').is(':visible')).toBe(true);\n+        expect(editor.value()).toEqual('hello wysiwyg @');\n+ \n+        crossvent.add(editor.editable, 'horsey-selected', onSelect);\n+ \n+        crossvent.fabricate($('.sey-list .sey-item:first')[0], \"click\");\n+\n+      }, 0);\n+\n+    }\n+ \n+    function onSelect() {\n+\n+      expect(editor.value()).toEqual('hello wysiwyg @hodor');\n+  \n+      editor.runCommand(function(chunks, mode) {\n+console.log(chunks,\"expect insertion point to be at the end\");","path":"spec/javascripts/banksy_spec.js","position":134,"original_position":134,"commit_id":"0fd202cb9b800307de5cc7fc0653dc36ee003e81","original_commit_id":"0fd202cb9b800307de5cc7fc0653dc36ee003e81","user":{"login":"jywarren","id":24359,"avatar_url":"https://avatars.githubusercontent.com/u/24359?v=3","gravatar_id":"","url":"https://api.github.com/users/jywarren","html_url":"https://github.com/jywarren","followers_url":"https://api.github.com/users/jywarren/followers","following_url":"https://api.github.com/users/jywarren/following{/other_user}","gists_url":"https://api.github.com/users/jywarren/gists{/gist_id}","starred_url":"https://api.github.com/users/jywarren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jywarren/subscriptions","organizations_url":"https://api.github.com/users/jywarren/orgs","repos_url":"https://api.github.com/users/jywarren/repos","events_url":"https://api.github.com/users/jywarren/events{/privacy}","received_events_url":"https://api.github.com/users/jywarren/received_events","type":"User","site_admin":false},"body":"Also, I think the before/after swap issue I'm chasing may not be an artifact of the timing of the tests themselves. I'm seeing the behavior also when manually entering `hi @h` and autocompleting, which you can try here: https://publiclab.org/editor/","created_at":"2016-07-29T14:09:37Z","updated_at":"2016-07-29T14:09:37Z","html_url":"https://github.com/bevacqua/banksy/pull/5#discussion_r72797197","pull_request_url":"https://api.github.com/repos/bevacqua/banksy/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/bevacqua/banksy/pulls/comments/72797197"},"html":{"href":"https://github.com/bevacqua/banksy/pull/5#discussion_r72797197"},"pull_request":{"href":"https://api.github.com/repos/bevacqua/banksy/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/bevacqua/banksy/pulls/5","id":71640716,"html_url":"https://github.com/bevacqua/banksy/pull/5","diff_url":"https://github.com/bevacqua/banksy/pull/5.diff","patch_url":"https://github.com/bevacqua/banksy/pull/5.patch","issue_url":"https://api.github.com/repos/bevacqua/banksy/issues/5","number":5,"state":"open","locked":false,"title":"entering values and triggering events in tests","user":{"login":"jywarren","id":24359,"avatar_url":"https://avatars.githubusercontent.com/u/24359?v=3","gravatar_id":"","url":"https://api.github.com/users/jywarren","html_url":"https://github.com/jywarren","followers_url":"https://api.github.com/users/jywarren/followers","following_url":"https://api.github.com/users/jywarren/following{/other_user}","gists_url":"https://api.github.com/users/jywarren/gists{/gist_id}","starred_url":"https://api.github.com/users/jywarren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jywarren/subscriptions","organizations_url":"https://api.github.com/users/jywarren/orgs","repos_url":"https://api.github.com/users/jywarren/repos","events_url":"https://api.github.com/users/jywarren/events{/privacy}","received_events_url":"https://api.github.com/users/jywarren/received_events","type":"User","site_admin":false},"body":"This pull request isn't ready -- it's a placeholder. \r\n\r\nIt will incorporate event triggering to cause a horsey to appear, to lay the groundwork for horsey testing. No animals harmed, etc.\r\n\r\n* [x] horsey appearances using new `enter()` test method (instead of horsey appearances using `editor.value()`)\r\n* [x] resolve `.is(':visible')` test inconsistency -- is the show/hide triggering asynchronous or something?\r\n* [x] resolve `banksy.js:84 Uncaught TypeError: Cannot read property 'before' of undefined` on triggering click on menu using jQuery. Possibly switch to a crossvent event.\r\n* [x] horsey appearances in different woofmark modes\r\n* [ ] documentation of where tests live and how to run them","created_at":"2016-05-26T23:33:30Z","updated_at":"2016-07-29T14:09:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"76540174e669a16d5590f495d569da9e4571f494","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/bevacqua/banksy/pulls/5/commits","review_comments_url":"https://api.github.com/repos/bevacqua/banksy/pulls/5/comments","review_comment_url":"https://api.github.com/repos/bevacqua/banksy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bevacqua/banksy/issues/5/comments","statuses_url":"https://api.github.com/repos/bevacqua/banksy/statuses/0fd202cb9b800307de5cc7fc0653dc36ee003e81","head":{"label":"jywarren:jasmine-test-events","ref":"jasmine-test-events","sha":"0fd202cb9b800307de5cc7fc0653dc36ee003e81","user":{"login":"jywarren","id":24359,"avatar_url":"https://avatars.githubusercontent.com/u/24359?v=3","gravatar_id":"","url":"https://api.github.com/users/jywarren","html_url":"https://github.com/jywarren","followers_url":"https://api.github.com/users/jywarren/followers","following_url":"https://api.github.com/users/jywarren/following{/other_user}","gists_url":"https://api.github.com/users/jywarren/gists{/gist_id}","starred_url":"https://api.github.com/users/jywarren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jywarren/subscriptions","organizations_url":"https://api.github.com/users/jywarren/orgs","repos_url":"https://api.github.com/users/jywarren/repos","events_url":"https://api.github.com/users/jywarren/events{/privacy}","received_events_url":"https://api.github.com/users/jywarren/received_events","type":"User","site_admin":false},"repo":{"id":59777302,"name":"banksy","full_name":"jywarren/banksy","owner":{"login":"jywarren","id":24359,"avatar_url":"https://avatars.githubusercontent.com/u/24359?v=3","gravatar_id":"","url":"https://api.github.com/users/jywarren","html_url":"https://github.com/jywarren","followers_url":"https://api.github.com/users/jywarren/followers","following_url":"https://api.github.com/users/jywarren/following{/other_user}","gists_url":"https://api.github.com/users/jywarren/gists{/gist_id}","starred_url":"https://api.github.com/users/jywarren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jywarren/subscriptions","organizations_url":"https://api.github.com/users/jywarren/orgs","repos_url":"https://api.github.com/users/jywarren/repos","events_url":"https://api.github.com/users/jywarren/events{/privacy}","received_events_url":"https://api.github.com/users/jywarren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jywarren/banksy","description":":city_sunrise: Street art between woofmark and horsey","fork":true,"url":"https://api.github.com/repos/jywarren/banksy","forks_url":"https://api.github.com/repos/jywarren/banksy/forks","keys_url":"https://api.github.com/repos/jywarren/banksy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jywarren/banksy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jywarren/banksy/teams","hooks_url":"https://api.github.com/repos/jywarren/banksy/hooks","issue_events_url":"https://api.github.com/repos/jywarren/banksy/issues/events{/number}","events_url":"https://api.github.com/repos/jywarren/banksy/events","assignees_url":"https://api.github.com/repos/jywarren/banksy/assignees{/user}","branches_url":"https://api.github.com/repos/jywarren/banksy/branches{/branch}","tags_url":"https://api.github.com/repos/jywarren/banksy/tags","blobs_url":"https://api.github.com/repos/jywarren/banksy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jywarren/banksy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jywarren/banksy/git/refs{/sha}","trees_url":"https://api.github.com/repos/jywarren/banksy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jywarren/banksy/statuses/{sha}","languages_url":"https://api.github.com/repos/jywarren/banksy/languages","stargazers_url":"https://api.github.com/repos/jywarren/banksy/stargazers","contributors_url":"https://api.github.com/repos/jywarren/banksy/contributors","subscribers_url":"https://api.github.com/repos/jywarren/banksy/subscribers","subscription_url":"https://api.github.com/repos/jywarren/banksy/subscription","commits_url":"https://api.github.com/repos/jywarren/banksy/commits{/sha}","git_commits_url":"https://api.github.com/repos/jywarren/banksy/git/commits{/sha}","comments_url":"https://api.github.com/repos/jywarren/banksy/comments{/number}","issue_comment_url":"https://api.github.com/repos/jywarren/banksy/issues/comments{/number}","contents_url":"https://api.github.com/repos/jywarren/banksy/contents/{+path}","compare_url":"https://api.github.com/repos/jywarren/banksy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jywarren/banksy/merges","archive_url":"https://api.github.com/repos/jywarren/banksy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jywarren/banksy/downloads","issues_url":"https://api.github.com/repos/jywarren/banksy/issues{/number}","pulls_url":"https://api.github.com/repos/jywarren/banksy/pulls{/number}","milestones_url":"https://api.github.com/repos/jywarren/banksy/milestones{/number}","notifications_url":"https://api.github.com/repos/jywarren/banksy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jywarren/banksy/labels{/name}","releases_url":"https://api.github.com/repos/jywarren/banksy/releases{/id}","deployments_url":"https://api.github.com/repos/jywarren/banksy/deployments","created_at":"2016-05-26T19:24:11Z","updated_at":"2016-05-26T19:24:12Z","pushed_at":"2016-07-19T15:26:41Z","git_url":"git://github.com/jywarren/banksy.git","ssh_url":"git@github.com:jywarren/banksy.git","clone_url":"https://github.com/jywarren/banksy.git","svn_url":"https://github.com/jywarren/banksy","homepage":"http://ponyfoo.com","size":16,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bevacqua:master","ref":"master","sha":"ea474c87f6da347ad2eac6e0a2d15aa3de43c779","user":{"login":"bevacqua","id":934293,"avatar_url":"https://avatars.githubusercontent.com/u/934293?v=3","gravatar_id":"","url":"https://api.github.com/users/bevacqua","html_url":"https://github.com/bevacqua","followers_url":"https://api.github.com/users/bevacqua/followers","following_url":"https://api.github.com/users/bevacqua/following{/other_user}","gists_url":"https://api.github.com/users/bevacqua/gists{/gist_id}","starred_url":"https://api.github.com/users/bevacqua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bevacqua/subscriptions","organizations_url":"https://api.github.com/users/bevacqua/orgs","repos_url":"https://api.github.com/users/bevacqua/repos","events_url":"https://api.github.com/users/bevacqua/events{/privacy}","received_events_url":"https://api.github.com/users/bevacqua/received_events","type":"User","site_admin":false},"repo":{"id":39496324,"name":"banksy","full_name":"bevacqua/banksy","owner":{"login":"bevacqua","id":934293,"avatar_url":"https://avatars.githubusercontent.com/u/934293?v=3","gravatar_id":"","url":"https://api.github.com/users/bevacqua","html_url":"https://github.com/bevacqua","followers_url":"https://api.github.com/users/bevacqua/followers","following_url":"https://api.github.com/users/bevacqua/following{/other_user}","gists_url":"https://api.github.com/users/bevacqua/gists{/gist_id}","starred_url":"https://api.github.com/users/bevacqua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bevacqua/subscriptions","organizations_url":"https://api.github.com/users/bevacqua/orgs","repos_url":"https://api.github.com/users/bevacqua/repos","events_url":"https://api.github.com/users/bevacqua/events{/privacy}","received_events_url":"https://api.github.com/users/bevacqua/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bevacqua/banksy","description":":city_sunrise: Street art between woofmark and horsey","fork":false,"url":"https://api.github.com/repos/bevacqua/banksy","forks_url":"https://api.github.com/repos/bevacqua/banksy/forks","keys_url":"https://api.github.com/repos/bevacqua/banksy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bevacqua/banksy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bevacqua/banksy/teams","hooks_url":"https://api.github.com/repos/bevacqua/banksy/hooks","issue_events_url":"https://api.github.com/repos/bevacqua/banksy/issues/events{/number}","events_url":"https://api.github.com/repos/bevacqua/banksy/events","assignees_url":"https://api.github.com/repos/bevacqua/banksy/assignees{/user}","branches_url":"https://api.github.com/repos/bevacqua/banksy/branches{/branch}","tags_url":"https://api.github.com/repos/bevacqua/banksy/tags","blobs_url":"https://api.github.com/repos/bevacqua/banksy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bevacqua/banksy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bevacqua/banksy/git/refs{/sha}","trees_url":"https://api.github.com/repos/bevacqua/banksy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bevacqua/banksy/statuses/{sha}","languages_url":"https://api.github.com/repos/bevacqua/banksy/languages","stargazers_url":"https://api.github.com/repos/bevacqua/banksy/stargazers","contributors_url":"https://api.github.com/repos/bevacqua/banksy/contributors","subscribers_url":"https://api.github.com/repos/bevacqua/banksy/subscribers","subscription_url":"https://api.github.com/repos/bevacqua/banksy/subscription","commits_url":"https://api.github.com/repos/bevacqua/banksy/commits{/sha}","git_commits_url":"https://api.github.com/repos/bevacqua/banksy/git/commits{/sha}","comments_url":"https://api.github.com/repos/bevacqua/banksy/comments{/number}","issue_comment_url":"https://api.github.com/repos/bevacqua/banksy/issues/comments{/number}","contents_url":"https://api.github.com/repos/bevacqua/banksy/contents/{+path}","compare_url":"https://api.github.com/repos/bevacqua/banksy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bevacqua/banksy/merges","archive_url":"https://api.github.com/repos/bevacqua/banksy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bevacqua/banksy/downloads","issues_url":"https://api.github.com/repos/bevacqua/banksy/issues{/number}","pulls_url":"https://api.github.com/repos/bevacqua/banksy/pulls{/number}","milestones_url":"https://api.github.com/repos/bevacqua/banksy/milestones{/number}","notifications_url":"https://api.github.com/repos/bevacqua/banksy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bevacqua/banksy/labels{/name}","releases_url":"https://api.github.com/repos/bevacqua/banksy/releases{/id}","deployments_url":"https://api.github.com/repos/bevacqua/banksy/deployments","created_at":"2015-07-22T09:02:36Z","updated_at":"2016-06-08T18:43:41Z","pushed_at":"2016-07-19T15:29:13Z","git_url":"git://github.com/bevacqua/banksy.git","ssh_url":"git@github.com:bevacqua/banksy.git","clone_url":"https://github.com/bevacqua/banksy.git","svn_url":"https://github.com/bevacqua/banksy","homepage":"https://ponyfoo.com","size":10,"stargazers_count":7,"watchers_count":7,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":5,"forks":2,"open_issues":5,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bevacqua/banksy/pulls/5"},"html":{"href":"https://github.com/bevacqua/banksy/pull/5"},"issue":{"href":"https://api.github.com/repos/bevacqua/banksy/issues/5"},"comments":{"href":"https://api.github.com/repos/bevacqua/banksy/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/bevacqua/banksy/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/bevacqua/banksy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bevacqua/banksy/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/bevacqua/banksy/statuses/0fd202cb9b800307de5cc7fc0653dc36ee003e81"}}}}
{"actor":{"display_login":"jywarren"}}