Files
716d43a9a8 Nuxt 3 migration (#4342)
Update the nuxt3 version.

Co-authored-by: Jonathan Adeline <jonathan@baserow.io>
Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
Co-authored-by: Cezary <cezary@baserow.io>
Co-authored-by: Tsering Paljor <tsering@baserow.io>
Co-authored-by: Przemyslaw Kukulski <przemyslaw+gh@baserow.io>
Co-authored-by: Bram <bram2w@users.noreply.github.com>
2026-01-22 10:27:19 +01:00

155 lines
3.3 KiB
JavaScript

import { MultipleSelectFieldType } from '@baserow/modules/database/fieldTypes'
import papa from '@baserow/modules/core/plugins/papa'
const richTextValuesForPasting = [
{
input: {
clipboardData: 'test,nonsense,test',
field: {
select_options: [
{ value: 'test', id: 1 },
{ value: 'test2', id: 2 },
],
},
},
output: [{ value: 'test', id: 1 }],
},
{
input: {
richClipboardData: [{ value: 'test', id: 10 }],
field: {
select_options: [
{ value: 'test', id: 1 },
{ value: 'test2', id: 2 },
],
},
},
output: [{ value: 'test', id: 1 }],
},
{
input: {
richClipboardData: [{ value: 'test', id: 2 }],
field: {
select_options: [
{ value: 'test', id: 1 },
{ value: 'test2', id: 2 },
],
},
},
output: [{ value: 'test2', id: 2 }],
},
{
input: {
richClipboardData: [{ value: 'random', id: 2 }],
field: {
select_options: [
{ value: 'test', id: 1 },
{ value: 'test', id: 2 },
],
},
},
output: [{ value: 'test', id: 2 }],
},
{
input: {
richClipboardData: [
{ value: 'test', id: 2 },
{ value: 'test', id: 50 },
{ value: 'unknown', id: 60 },
],
field: {
select_options: [
{ value: 'test', id: 1 },
{ value: 'test2', id: 2 },
],
},
},
output: [
{ value: 'test2', id: 2 },
{ value: 'test', id: 1 },
],
},
{
input: {
richClipboardData: [
{ value: 'test', id: 2 },
{ value: 'test', id: 2 },
],
field: {
select_options: [
{ value: 'test', id: 1 },
{ value: 'test2', id: 2 },
],
},
},
output: [{ value: 'test2', id: 2 }],
},
{
input: {
clipboardData: 'test,test2',
richClipboardData: 'invalid',
field: {
select_options: [
{ value: 'test', id: 1 },
{ value: 'test2', id: 2 },
],
},
},
output: [
{ value: 'test', id: 1 },
{ value: 'test2', id: 2 },
],
},
{
input: {
clipboardData: 'test,test',
richClipboardData: 'invalid',
field: {
select_options: [
{ value: 'test', id: 1 },
{ value: 'test', id: 2 },
],
},
},
output: [
{ value: 'test', id: 1 },
{ value: 'test', id: 2 },
],
},
{
input: {
clipboardData: 'test,test2,test,test3',
richClipboardData: 'invalid',
field: {
select_options: [
{ value: 'test', id: 1 },
{ value: 'test2', id: 10 },
{ value: 'test', id: 3 },
],
},
},
output: [
{ value: 'test', id: 1 },
{ value: 'test2', id: 10 },
{ value: 'test', id: 3 },
],
},
]
describe('Rich test pasting tests', () => {
test.each(richTextValuesForPasting)(
'Verify that prepareValueForPaste returns the expected output for multi select' +
' type: %j',
({ input, output }) => {
const nuxtApp = useNuxtApp()
expect(
new MultipleSelectFieldType({ app: nuxtApp }).prepareValueForPaste(
input.field,
input.clipboardData,
input.richClipboardData
)
).toStrictEqual(output)
}
)
})