Merge branch 'master' of https://github.com/primefaces/primevue
commit
db198275a4
|
@ -75,6 +75,10 @@ const MessageEvents = [
|
|||
description: 'Browser event'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'life-end',
|
||||
description: "Callback to invoke when the message's timeout is over."
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ describe('Checkbox.vue', () => {
|
|||
it('should exist', async () => {
|
||||
await wrapper.setProps({ modelValue: true });
|
||||
|
||||
expect(wrapper.find('.p-checkbox-checked').exists()).toBe(true);
|
||||
expect(wrapper.find('.p-checkbox-box.p-highlight').exists()).toBe(true);
|
||||
expect(wrapper.find('.p-checkbox.p-highlight').exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -140,11 +140,12 @@ export default {
|
|||
},
|
||||
onPaste(event) {
|
||||
if (this.separator) {
|
||||
let separator = this.separator.replace('\\n', '\n').replace('\\r', '\r').replace('\\t', '\t');
|
||||
let pastedData = (event.clipboardData || window['clipboardData']).getData('Text');
|
||||
|
||||
if (pastedData) {
|
||||
let value = this.modelValue || [];
|
||||
let pastedValues = pastedData.split(this.separator);
|
||||
let pastedValues = pastedData.split(separator);
|
||||
|
||||
pastedValues = pastedValues.filter((val) => this.allowDuplicate || value.indexOf(val) === -1);
|
||||
value = [...value, ...pastedValues];
|
||||
|
|
|
@ -702,7 +702,7 @@ describe('DataTable.vue', () => {
|
|||
it('should expand a row', async () => {
|
||||
await wrapper.setProps({ expandedRows: [] });
|
||||
|
||||
await wrapper.vm.toggleRow({ originalEvent: {}, data: smallData[0] });
|
||||
await wrapper.vm.toggleRow({ originalEvent: {}, data: smallData[0], expanded: true });
|
||||
|
||||
expect(wrapper.emitted()['update:expandedRows'][0][0]).toEqual([smallData[0]]);
|
||||
expect(wrapper.emitted()['row-expand'][0][0].data).toEqual(smallData[0]);
|
||||
|
@ -915,7 +915,7 @@ describe('DataTable.vue', () => {
|
|||
|
||||
await wrapper.vm.onColumnResize({});
|
||||
|
||||
expect(wrapper.find('.p-column-resizer-helper').attributes().style).toContain('display: block;');
|
||||
expect(wrapper.find('.p-column-resizer-helper').attributes().style).toContain('display: none; height: 0px; top: 0px;');
|
||||
});
|
||||
|
||||
it('should fit mode column resize end', async () => {
|
||||
|
@ -1000,7 +1000,7 @@ describe('DataTable.vue', () => {
|
|||
|
||||
await wrapper.vm.onColumnResize({});
|
||||
|
||||
expect(wrapper.find('.p-column-resizer-helper').attributes().style).toContain('display: block;');
|
||||
expect(wrapper.find('.p-column-resizer-helper').attributes().style).toContain('display: none; height: 0px; top: 0px;');
|
||||
});
|
||||
|
||||
it('should fit mode column resize end', async () => {
|
||||
|
|
|
@ -877,9 +877,16 @@ export default {
|
|||
selectionEnd = sRegex.lastIndex + tRegex.lastIndex;
|
||||
this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
|
||||
} else if (newLength === currentLength) {
|
||||
if (operation === 'insert' || operation === 'delete-back-single') this.$refs.input.$el.setSelectionRange(selectionEnd + 1, selectionEnd + 1);
|
||||
else if (operation === 'delete-single') this.$refs.input.$el.setSelectionRange(selectionEnd - 1, selectionEnd - 1);
|
||||
else if (operation === 'delete-range' || operation === 'spin') this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
|
||||
if (operation === 'insert' || operation === 'delete-back-single') {
|
||||
const re = /[.,]/g;
|
||||
const newSelectionEnd = selectionEnd + Number(re.test(value) || re.test(insertedValueStr));
|
||||
|
||||
this.$refs.input.$el.setSelectionRange(newSelectionEnd, newSelectionEnd);
|
||||
} else if (operation === 'delete-single') {
|
||||
this.$refs.input.$el.setSelectionRange(selectionEnd - 1, selectionEnd - 1);
|
||||
} else if (operation === 'delete-range' || operation === 'spin') {
|
||||
this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
|
||||
}
|
||||
} else if (operation === 'delete-back-single') {
|
||||
let prevChar = inputValue.charAt(selectionEnd - 1);
|
||||
let nextChar = inputValue.charAt(selectionEnd);
|
||||
|
|
|
@ -8,13 +8,13 @@ describe('InputSwitch.vue', () => {
|
|||
expect(wrapper.find('.p-inputswitch.p-component').exists()).toBe(true);
|
||||
expect(wrapper.find('.p-inputswitch-slider').exists()).toBe(true);
|
||||
|
||||
await wrapper.trigger('click');
|
||||
await wrapper.vm.onChange({});
|
||||
|
||||
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([true]);
|
||||
|
||||
await wrapper.setProps({ modelValue: true });
|
||||
|
||||
expect(wrapper.vm.checked).toBe(true);
|
||||
expect(wrapper.find('.p-inputswitch').classes()).toContain('p-inputswitch-checked');
|
||||
expect(wrapper.find('.p-inputswitch').classes()).toContain('p-highlight');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -218,6 +218,10 @@ export interface MessageEmits {
|
|||
* @param {Event} event - Browser event.
|
||||
*/
|
||||
close(event: Event): void;
|
||||
/**
|
||||
* Callback to invoke when the message's timeout is over.
|
||||
*/
|
||||
'life-end'(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,7 +32,7 @@ import BaseMessage from './BaseMessage.vue';
|
|||
export default {
|
||||
name: 'Message',
|
||||
extends: BaseMessage,
|
||||
emits: ['close'],
|
||||
emits: ['close', 'life-end'],
|
||||
timeout: null,
|
||||
data() {
|
||||
return {
|
||||
|
@ -59,6 +59,7 @@ export default {
|
|||
closeAfterDelay() {
|
||||
setTimeout(() => {
|
||||
this.visible = false;
|
||||
this.$emit('life-end');
|
||||
}, this.life);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -13,21 +13,20 @@ describe('RadioButton.vue', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('shoukd exist', () => {
|
||||
it('should exist', () => {
|
||||
expect(wrapper.find('.p-radiobutton.p-component').exists()).toBe(true);
|
||||
expect(wrapper.find('input').attributes().type).toBe('radio');
|
||||
});
|
||||
|
||||
it('When disabled true and onClick triggered click emit should not be called', async () => {
|
||||
it('When disabled true and onChange triggered click emit should not be called', async () => {
|
||||
await wrapper.setProps({ disabled: true });
|
||||
await wrapper.vm.onClick();
|
||||
await wrapper.trigger('change');
|
||||
|
||||
expect(wrapper.emitted()['click']).toEqual(undefined);
|
||||
expect(wrapper.emitted()['update:modelValue']).toEqual(undefined);
|
||||
expect(wrapper.emitted()['change']).toBeFalsy();
|
||||
});
|
||||
|
||||
it('When disabled false and onClick triggered click emit should be called', async () => {
|
||||
await wrapper.vm.onClick();
|
||||
it('When disabled false and onChange triggered click emit should be called', async () => {
|
||||
await wrapper.vm.onChange({});
|
||||
|
||||
expect(wrapper.emitted()['update:modelValue'].length).toEqual(1);
|
||||
expect(wrapper.emitted().change.length).toEqual(1);
|
||||
|
@ -35,24 +34,16 @@ describe('RadioButton.vue', () => {
|
|||
|
||||
it('When value and modelValue equal and onClick triggered change emit should not be called', async () => {
|
||||
await wrapper.setProps({ modelValue: 'test', value: 'test' });
|
||||
await wrapper.vm.onClick();
|
||||
await wrapper.vm.onChange({});
|
||||
|
||||
expect(wrapper.emitted()['change']).toEqual(undefined);
|
||||
expect(wrapper.emitted()['change'][0][0]).toEqual({});
|
||||
});
|
||||
|
||||
it('When modelValue changed, Checked should be effected', async () => {
|
||||
await wrapper.setProps({ modelValue: 'Tatooine' });
|
||||
|
||||
expect(wrapper.vm.checked).toBe(true);
|
||||
expect(wrapper.find('.p-radiobutton').classes()).toContain('p-radiobutton-checked');
|
||||
});
|
||||
|
||||
it('When component cliked OnClick method should be called', async () => {
|
||||
const spy = vi.spyOn(wrapper.vm, 'onClick');
|
||||
|
||||
await wrapper.find('.p-radiobutton').trigger('click');
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(wrapper.find('.p-radiobutton').classes()).toContain('p-highlight');
|
||||
});
|
||||
|
||||
it('When component focused onFocus method should be called', async () => {
|
||||
|
@ -65,13 +56,6 @@ describe('RadioButton.vue', () => {
|
|||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('When onFocus method triggered, false should be true', async () => {
|
||||
await wrapper.vm.onFocus();
|
||||
|
||||
expect(wrapper.vm.focused).toBeTruthy();
|
||||
expect(wrapper.emitted().focus.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('When component blur onBlur method should be called', async () => {
|
||||
await wrapper.setProps({ inputId: 'test' });
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ describe('Sidebar.vue', () => {
|
|||
it('When keydown is triggered , hide method should be triggered', async () => {
|
||||
const hideSpy = vi.spyOn(wrapper.vm, 'hide');
|
||||
|
||||
await wrapper.find('.p-sidebar').trigger('keydown', { code: 'Escape' });
|
||||
await wrapper.vm.onKeydown({ code: 'Escape' });
|
||||
|
||||
expect(hideSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
@ -25,13 +25,13 @@ describe('ToggleButton', () => {
|
|||
expect(wrapper.find('span.pi-check').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('should click works', async () => {
|
||||
await wrapper.vm.onClick({});
|
||||
it('should change works', async () => {
|
||||
await wrapper.vm.onChange({});
|
||||
|
||||
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([true]);
|
||||
|
||||
await wrapper.setProps({ modelValue: true });
|
||||
await wrapper.vm.onClick({});
|
||||
await wrapper.vm.onChange({});
|
||||
|
||||
expect(wrapper.emitted()['update:modelValue'][1]).toEqual([false]);
|
||||
});
|
||||
|
|
|
@ -10,35 +10,6 @@ describe('TriStateCheckbox.vue', () => {
|
|||
wrapper = mount(TriStateCheckbox);
|
||||
});
|
||||
|
||||
it('When onClick method triggered some methods effect', () => {
|
||||
const mockUpdateModel = vi.fn();
|
||||
|
||||
wrapper.vm.updateModel = mockUpdateModel;
|
||||
|
||||
wrapper.vm.onClick('test');
|
||||
|
||||
expect(wrapper.vm.updateModel).toBeCalled();
|
||||
expect(wrapper.emitted()['click']).toBeTruthy();
|
||||
expect(wrapper.emitted()['change']).toBeTruthy();
|
||||
});
|
||||
|
||||
it('When event.code is not equal Enter methods should not be effected', async () => {
|
||||
wrapper.vm.onKeyDown({ code: 'test' });
|
||||
|
||||
expect(wrapper.emitted().keydown).toBeFalsy();
|
||||
});
|
||||
|
||||
it('When event.code is equal Enter some methods should be triggered', async () => {
|
||||
const mockUpdateModel = vi.fn();
|
||||
|
||||
wrapper.vm.updateModel = mockUpdateModel;
|
||||
|
||||
wrapper.vm.onKeyDown({ code: 'Enter', preventDefault: () => {} });
|
||||
|
||||
expect(wrapper.vm.updateModel).toBeCalled();
|
||||
expect(wrapper.emitted().keydown).toBeTruthy();
|
||||
});
|
||||
|
||||
it('When onBlur is triggered focused property should be false', async () => {
|
||||
wrapper.vm.onBlur();
|
||||
|
||||
|
@ -52,15 +23,15 @@ describe('UpdateModel method tests', () => {
|
|||
wrapper = mount(TriStateCheckbox);
|
||||
});
|
||||
|
||||
it('When disable props true updateModal should not triggered emit', async () => {
|
||||
it('When disable props true change emit should not triggered', async () => {
|
||||
await wrapper.setProps({
|
||||
disabled: true,
|
||||
modelValue: null
|
||||
});
|
||||
|
||||
wrapper.vm.updateModel();
|
||||
await wrapper.trigger('change');
|
||||
|
||||
expect(wrapper.emitted()['update:modelValue']).toBeFalsy();
|
||||
expect(wrapper.emitted()['change']).toBeFalsy();
|
||||
});
|
||||
|
||||
it('When disable props false updateModal should triggered emit', () => {
|
||||
|
|
|
@ -35239,6 +35239,12 @@
|
|||
],
|
||||
"returnType": "void",
|
||||
"description": "Callback to invoke when a message is closed."
|
||||
},
|
||||
{
|
||||
"name": "life-end",
|
||||
"parameters": [],
|
||||
"returnType": "void",
|
||||
"description": "Callback to invoke when the message's timeout is over."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue