From bf7a3130aeff0a954576d404f157fae31a0f3cd6 Mon Sep 17 00:00:00 2001 From: Phan An Date: Mon, 9 May 2022 12:21:21 +0200 Subject: [PATCH] feat(test): add PreferencesForm component tests --- .../PreferencesForm.spec.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 resources/assets/js/components/profile-preferences/PreferencesForm.spec.ts diff --git a/resources/assets/js/components/profile-preferences/PreferencesForm.spec.ts b/resources/assets/js/components/profile-preferences/PreferencesForm.spec.ts new file mode 100644 index 00000000..18bfebd7 --- /dev/null +++ b/resources/assets/js/components/profile-preferences/PreferencesForm.spec.ts @@ -0,0 +1,20 @@ +import { expect, it } from 'vitest' +import isMobile from 'ismobilejs' +import ComponentTestCase from '@/__tests__/ComponentTestCase' +import PreferencesForm from './PreferencesForm.vue' + +new class extends ComponentTestCase { + protected test () { + it('has "Transcode on mobile" option for mobile users', () => { + isMobile.phone = true + const { getByLabelText } = this.render(PreferencesForm) + getByLabelText('Convert and play media at 128kbps on mobile') + }) + + it('does not have "Transcode on mobile" option for non-mobile users', async () => { + isMobile.phone = false + const { queryByLabelText } = this.render(PreferencesForm) + expect(await queryByLabelText('Convert and play media at 128kbps on mobile')).toBeNull() + }) + } +}