Skip to content

Commit

Permalink
feat: mirror all pre tag events (#58)
Browse files Browse the repository at this point in the history
Fix #24
  • Loading branch information
jefrydco authored Feb 11, 2020
1 parent efdd959 commit 6b5151a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
autocomplete="off"
autocorrect="off"
data-gramm="false"
v-on="$listeners"
></pre>
</div>
</template>
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/Editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,31 @@ describe("Editor.vue", () => {
expect(mockHandler).toHaveBeenCalled();
});

it("emits all pre events", () => {
const mockHandler = jest.fn();
const compiled = compileToFunctions(
'<div><Editor class="foo" @focus="eventHandler" @blur="eventHandler" @input="eventHandler" /></div>'
);
const wrapper = mount(compiled, {
data: () => ({
code: "test"
}),
stubs: {
Editor
},
methods: {
eventHandler: mockHandler
}
});
const $pre = wrapper.find("pre");

$pre.element.dispatchEvent(new Event("focus"));
$pre.element.dispatchEvent(new Event("blur"));
$pre.element.dispatchEvent(new Event("input"));

expect(mockHandler).toHaveBeenCalledTimes(3);
});

it("renders with null value", () => {
const code = null;
const wrapper = mount(Editor, {
Expand Down

0 comments on commit 6b5151a

Please sign in to comment.