Skip to content

Commit

Permalink
XWIKI-18711: Properties of type number cannot be switched to edit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelleduc committed Jun 3, 2021
1 parent aa24112 commit 8cef3ce
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
@@ -0,0 +1,53 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

import DisplayerNumber from "../../../displayers/DisplayerNumber";
import {initWrapper} from "./displayerTestsHelper";

describe('DisplayerNumber.vue', () => {
it('Renders an entry in view mode', () => {
const wrapper = initWrapper(DisplayerNumber, {
props: {
propertyId: 'quantity',
entry: {
quantity: 42
}
}
})
expect(wrapper.text()).toMatch('42')
})

it('Renders an entry in edit mode', async () => {
const wrapper = initWrapper(DisplayerNumber, {
props: {
propertyId: 'quantity',
entry: {
quantity: 42
}
}
})

const viewerDiv = wrapper.find('div[tabindex="0"]');
await viewerDiv.trigger('dblclick');

expect(wrapper.find('input').element.value).toBe('42')
expect(wrapper.find('input').element).toHaveFocus()
})
})
Expand Up @@ -32,6 +32,8 @@
class="displayer-number"
:property-id="propertyId"
:entry="entry"
:is-view.sync="isView"
@saveEdit="genericSave"
>

<!-- Keep the default Viewer widget -->
Expand All @@ -48,6 +50,7 @@
import displayerMixin from "./displayerMixin.js";
import BaseDisplayer from "./BaseDisplayer.vue";
import displayerStatesMixin from "./displayerStatesMixin";
export default {
Expand All @@ -58,7 +61,7 @@ export default {
},
// Add the displayerMixin to get access to all the displayers methods and computed properties inside this component
mixins: [displayerMixin],
mixins: [displayerMixin, displayerStatesMixin],
};
</script>
Expand Down

0 comments on commit 8cef3ce

Please sign in to comment.