2021-07-11 19:01:21 +02:00
|
|
|
import Picker from '../../../src/picker/PickerElement'
|
|
|
|
import { basicAfterEach, basicBeforeEach, FR_EMOJI, mockFrenchDataSource, tick } from '../shared'
|
|
|
|
import { DEFAULT_DATA_SOURCE } from '../../../src/database/constants'
|
|
|
|
|
|
|
|
describe('properties', () => {
|
|
|
|
beforeEach(async () => {
|
2023-06-18 21:27:19 +02:00
|
|
|
await basicBeforeEach()
|
|
|
|
await mockFrenchDataSource()
|
|
|
|
await tick(40)
|
|
|
|
})
|
|
|
|
afterEach(async () => {
|
|
|
|
await tick(40)
|
|
|
|
await basicAfterEach()
|
|
|
|
await tick(40)
|
2021-07-11 19:01:21 +02:00
|
|
|
})
|
|
|
|
|
2024-03-19 06:57:09 +01:00
|
|
|
test.skip('setting initial dataSource and locale', async () => {
|
2021-07-11 19:01:21 +02:00
|
|
|
const picker = new Picker()
|
|
|
|
picker.locale = 'fr'
|
|
|
|
picker.dataSource = FR_EMOJI
|
|
|
|
|
|
|
|
document.body.appendChild(picker)
|
|
|
|
|
2022-04-17 18:00:15 +02:00
|
|
|
await tick(40)
|
2021-07-11 19:01:21 +02:00
|
|
|
|
2024-03-09 22:21:00 +01:00
|
|
|
expect(fetch.calls().length).toBe(1)
|
|
|
|
expect(fetch.lastUrl()).toBe(FR_EMOJI)
|
2024-03-17 18:47:53 +01:00
|
|
|
expect(fetch.lastOptions().method).toBe(undefined)
|
2021-07-11 19:01:21 +02:00
|
|
|
|
|
|
|
expect(picker.locale).toEqual('fr')
|
|
|
|
expect(picker.dataSource).toEqual(FR_EMOJI)
|
|
|
|
expect(picker.getAttribute('locale')).toEqual(null)
|
|
|
|
expect(picker.getAttribute('data-source')).toEqual(null)
|
|
|
|
|
|
|
|
document.body.removeChild(picker)
|
2022-04-17 18:00:15 +02:00
|
|
|
await tick(40)
|
2021-07-11 19:01:21 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
test('setting initial dataSource', async () => {
|
|
|
|
const picker = new Picker()
|
|
|
|
picker.dataSource = FR_EMOJI
|
|
|
|
|
|
|
|
document.body.appendChild(picker)
|
|
|
|
|
2022-04-17 18:00:15 +02:00
|
|
|
await tick(40)
|
2021-07-11 19:01:21 +02:00
|
|
|
|
2024-03-19 06:57:09 +01:00
|
|
|
console.info(fetch.calls()[0][1].signal.aborted)
|
|
|
|
console.info(fetch.calls()[1][1].signal.aborted)
|
|
|
|
console.info(fetch.calls())
|
2024-03-09 22:21:00 +01:00
|
|
|
expect(fetch.calls().length).toBe(1)
|
|
|
|
expect(fetch.lastUrl()).toBe(FR_EMOJI)
|
2024-03-17 18:47:53 +01:00
|
|
|
expect(fetch.lastOptions().method).toBe(undefined)
|
2021-07-11 19:01:21 +02:00
|
|
|
|
|
|
|
expect(picker.locale).toEqual('en')
|
|
|
|
expect(picker.dataSource).toEqual(FR_EMOJI)
|
|
|
|
expect(picker.getAttribute('locale')).toEqual(null)
|
|
|
|
expect(picker.getAttribute('data-source')).toEqual(null)
|
|
|
|
|
|
|
|
document.body.removeChild(picker)
|
2022-04-17 18:00:15 +02:00
|
|
|
await tick(40)
|
2021-07-11 19:01:21 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
test('setting initial locale', async () => {
|
|
|
|
const picker = new Picker()
|
|
|
|
picker.locale = 'fr'
|
|
|
|
|
|
|
|
document.body.appendChild(picker)
|
|
|
|
|
2022-04-17 18:00:15 +02:00
|
|
|
await tick(40)
|
2021-07-11 19:01:21 +02:00
|
|
|
|
2024-03-09 22:21:00 +01:00
|
|
|
expect(fetch.calls().length).toBe(1)
|
|
|
|
expect(fetch.lastUrl()).toBe(DEFAULT_DATA_SOURCE)
|
2024-03-17 18:47:53 +01:00
|
|
|
expect(fetch.lastOptions().method).toBe(undefined)
|
2021-07-11 19:01:21 +02:00
|
|
|
|
|
|
|
expect(picker.locale).toEqual('fr')
|
|
|
|
expect(picker.dataSource).toEqual(DEFAULT_DATA_SOURCE)
|
|
|
|
expect(picker.getAttribute('locale')).toEqual(null)
|
|
|
|
expect(picker.getAttribute('data-source')).toEqual(null)
|
|
|
|
|
|
|
|
document.body.removeChild(picker)
|
2022-04-17 18:00:15 +02:00
|
|
|
await tick(40)
|
2021-07-11 19:01:21 +02:00
|
|
|
})
|
|
|
|
})
|