Skip to content

Commit

Permalink
feat(useLinks): update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Red-Asuka committed Dec 11, 2024
1 parent a685ce9 commit d2fabe7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/ui/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ declare module 'vue' {
ElIconDelete: typeof import('@element-plus/icons-vue')['Delete']
ElIconDownload: typeof import('@element-plus/icons-vue')['Download']
ElIconPrinter: typeof import('@element-plus/icons-vue')['Printer']
ElIconRight: typeof import('@element-plus/icons-vue')['Right']
ElIconUpload: typeof import('@element-plus/icons-vue')['Upload']
ElIconWarning: typeof import('@element-plus/icons-vue')['Warning']
ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
ElMain: typeof import('element-plus/es')['ElMain']
ElOption: typeof import('element-plus/es')['ElOption']
ElPopover: typeof import('element-plus/es')['ElPopover']
ElRow: typeof import('element-plus/es')['ElRow']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
Expand Down
28 changes: 26 additions & 2 deletions packages/ui/src/composables/__test__/useLinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('useLinks', () => {
faq: 'https://mqttx.app/zh/docs/faq?utm_source=mqttx&utm_medium=referral&utm_campaign=about-to-faq',
MQTTX: 'https://mqttx.app/zh?utm_source=mqttx&utm_medium=referral&utm_campaign=about-to-mqttx',
EMQ: 'https://emqx.com/zh?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-homepage',
EMQXCloud: 'https://emqx.com/zh/cloud?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud',
EMQXCloud: 'https://accounts-zh.emqx.com/signup?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud&continue=https%3A%2F%2Fcloud.emqx.com%2Fconsole%2Fdeployments%2Fnew',
})

await setupI18n('en')
Expand All @@ -108,7 +108,7 @@ describe('useLinks', () => {
faq: 'https://mqttx.app/docs/faq?utm_source=mqttx&utm_medium=referral&utm_campaign=about-to-faq',
MQTTX: 'https://mqttx.app?utm_source=mqttx&utm_medium=referral&utm_campaign=about-to-mqttx',
EMQ: 'https://emqx.com/en?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-homepage',
EMQXCloud: 'https://emqx.com/en/cloud?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud',
EMQXCloud: 'https://accounts.emqx.com/signup?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud&continue=https%3A%2F%2Fcloud.emqx.com%2Fconsole%2Fdeployments%2Fnew',
})
})

Expand All @@ -135,4 +135,28 @@ describe('useLinks', () => {
blogUtm: '?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-help-to-blog',
})
})

it('should return correct authSite based on locale', async () => {
await setupI18n('zh')
const wrapper = mount(createTestComponent(), { global: { plugins: [i18n] } })
expect(wrapper.vm.authSite).toBe('https://accounts-zh.emqx.com')

await setupI18n('ja')
expect(wrapper.vm.authSite).toBe('https://accounts.emqx.com/ja')

await setupI18n('en')
expect(wrapper.vm.authSite).toBe('https://accounts.emqx.com')
})

it('should return correct cloudTrial link', async () => {
await setupI18n('zh')
const wrapper = mount(createTestComponent(), { global: { plugins: [i18n] } })
expect(wrapper.vm.cloudTrial).toBe('https://accounts-zh.emqx.com/signup?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud&continue=https%3A%2F%2Fcloud.emqx.com%2Fconsole%2Fdeployments%2Fnew')

await setupI18n('ja')
expect(wrapper.vm.cloudTrial).toBe('https://accounts.emqx.com/ja/signup?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud&continue=https%3A%2F%2Fcloud.emqx.com%2Fconsole%2Fdeployments%2Fnew')

await setupI18n('en')
expect(wrapper.vm.cloudTrial).toBe('https://accounts.emqx.com/signup?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud&continue=https%3A%2F%2Fcloud.emqx.com%2Fconsole%2Fdeployments%2Fnew')
})
})

0 comments on commit d2fabe7

Please sign in to comment.