diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-05-01 13:51:07 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-05-01 13:51:07 +0900 |
commit | 4d7c24f38a6861e1d498b6e7dd5c7be2d1a0ad15 (patch) | |
tree | 0948f730a25eeda127c56a0f01009f14d066e4dc /test/settings/components/form/keymaps-form.test.jsx | |
parent | 177940981ed9c4f096ad7db20f0b7ee044fd7b17 (diff) | |
parent | fb8a0f36aa4d070df936cc7598ef8dd988ee1b15 (diff) |
Merge remote-tracking branch 'origin/master' into background-adjacent-tabs
Diffstat (limited to 'test/settings/components/form/keymaps-form.test.jsx')
-rw-r--r-- | test/settings/components/form/keymaps-form.test.jsx | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/settings/components/form/keymaps-form.test.jsx b/test/settings/components/form/keymaps-form.test.jsx new file mode 100644 index 0000000..e9f9359 --- /dev/null +++ b/test/settings/components/form/keymaps-form.test.jsx @@ -0,0 +1,53 @@ +import { expect } from 'chai'; +import { h, render } from 'preact'; +import KeymapsForm from 'settings/components/form/keymaps-form' + +describe("settings/form/KeymapsForm", () => { + beforeEach(() => { + document.body.innerHTML = ''; + }); + + describe('render', () => { + it('renders KeymapsForm', () => { + render(<KeymapsForm value={{ + 'scroll.vertically?{"count":1}': 'j', + 'scroll.vertically?{"count":-1}': 'k', + }} />, document.body); + + let inputj = document.getElementById('scroll.vertically?{"count":1}'); + let inputk = document.getElementById('scroll.vertically?{"count":-1}'); + + expect(inputj.value).to.equal('j'); + expect(inputk.value).to.equal('k'); + }); + + it('renders blank value', () => { + render(<KeymapsForm />, document.body); + + let inputj = document.getElementById('scroll.vertically?{"count":1}'); + let inputk = document.getElementById('scroll.vertically?{"count":-1}'); + + expect(inputj.value).to.be.empty; + expect(inputk.value).to.be.empty; + }); + }); + + describe('onChange event', () => { + it('invokes onChange event on edit', (done) => { + render(<KeymapsForm + value={{ + 'scroll.vertically?{"count":1}': 'j', + 'scroll.vertically?{"count":-1}': 'k', + }} + onChange={value => { + expect(value['scroll.vertically?{"count":1}']).to.equal('jjj'); + + done(); + }} />, document.body); + + let input = document.getElementById('scroll.vertically?{"count":1}'); + input.value = 'jjj'; + input.dispatchEvent(new Event('change')) + }); + }); +}); |