koel/resources/assets/js/components/profile-preferences/PreferencesForm.spec.ts

29 lines
993 B
TypeScript
Raw Normal View History

import { expect, it } from 'vitest'
import { screen } from '@testing-library/vue'
import isMobile from 'ismobilejs'
import { commonStore } from '@/stores'
2022-05-13 17:58:38 +00:00
import UnitTestCase from '@/__tests__/UnitTestCase'
import PreferencesForm from './PreferencesForm.vue'
2022-05-13 17:58:38 +00:00
new class extends UnitTestCase {
protected test () {
it('has "Transcode on mobile" option for mobile users', () => {
isMobile.phone = true
this.render(PreferencesForm)
screen.getByTestId('transcode_on_mobile')
})
it('does not have "Transcode on mobile" option for non-mobile users', async () => {
isMobile.phone = false
this.render(PreferencesForm)
expect(screen.queryByTestId('transcode_on_mobile')).toBeNull()
})
it('does not have "Transcode on mobile" option if transcoding is not supported', async () => {
isMobile.phone = true
commonStore.state.supports_transcoding = false
expect(screen.queryByTestId('transcode_on_mobile')).toBeNull()
})
}
}