Skip to content

Commit

Permalink
add tests, add placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
Esvalirion committed Jan 27, 2021
1 parent a438ecf commit c5c1037
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/qComponents/QInputNumber/QInputNumber.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Component from './src/QInputNumber.vue';

describe('QInputNumber', () => {
it('should match snapshot', async () => {
const { element } = shallowMount(Component);

expect(element).toMatchSnapshot();
});

it('should match snapshot without controls', async () => {
const { element } = shallowMount(Component, {
propsData: {
controls: false
}
});

expect(element).toMatchSnapshot();
});

it('data should match snapshot', () => {
expect(Component.data()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`QInputNumber data should match snapshot 1`] = `
Object {
"number": null,
"prevNumber": null,
"userNumber": null,
}
`;

exports[`QInputNumber should match snapshot 1`] = `
<div
class="q-input-number q-input-number_with-controls"
>
<button
class="q-input-number__button_decrease q-input-number__button q-icon-minus"
/>
<q-input-stub
autocomplete="off"
class="q-input-number__input"
label=""
suffixicon=""
tabindex=""
type="text"
validateevent="true"
value=""
/>
<button
class="q-input-number__button_increase q-input-number__button q-icon-plus"
/>
</div>
`;

exports[`QInputNumber should match snapshot without controls 1`] = `
<div
class="q-input-number"
>
<!---->
<q-input-stub
autocomplete="off"
class="q-input-number__input"
label=""
suffixicon=""
tabindex=""
type="text"
validateevent="true"
value=""
/>
<!---->
</div>
`;
5 changes: 5 additions & 0 deletions src/qComponents/QInputNumber/src/QInputNumber.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
:value="currentValue"
class="q-input-number__input"
:disabled="isDisabled"
:placeholder="placeholder"
@blur="handleBlur"
@focus="handleFocus"
@input="handleChangeInput($event, 'input')"
Expand Down Expand Up @@ -88,6 +89,10 @@ export default {
type: Boolean,
default: true
},
placeholder: {
type: String,
default: null
},
value: {
type: [Number, String],
default: null,
Expand Down
3 changes: 1 addition & 2 deletions stories/components/QInputNumber.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const Default = (_, { argTypes }) => ({
props: Object.keys(argTypes).filter(val => val !== 'value'),
data() {
return {
value: '2'
value: 2
};
},
methods: {
Expand All @@ -35,4 +35,3 @@ export const Default = (_, { argTypes }) => ({
});

Default.storyName = 'Default';
Default.args = { value: 17 };

0 comments on commit c5c1037

Please sign in to comment.