CommonThirdPartyAuthenticationButton.spec.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { expect } from 'vitest'
  3. import renderComponent from '#tests/support/components/renderComponent.ts'
  4. import { setCSRFToken } from '#shared/server/apollo/utils/csrfToken.ts'
  5. import CommonThirdPartyAuthenticationButton from '#desktop/components/CommonThirdPartyAuthenticationButton/CommonThirdPartyAuthenticationButton.vue'
  6. const token = '12345'
  7. const url = '/auth/github'
  8. setCSRFToken(token)
  9. describe('CommonThirdPartyAuthenticationButton', () => {
  10. it('renders with default prop values', () => {
  11. const view = renderComponent(CommonThirdPartyAuthenticationButton, {
  12. props: {
  13. url,
  14. },
  15. })
  16. expect(view.getByRole('form')).toHaveFormValues({
  17. authenticity_token: token,
  18. })
  19. })
  20. it('renders with prop values', () => {
  21. const view = renderComponent(CommonThirdPartyAuthenticationButton, {
  22. props: {
  23. buttonLabel: 'GitHub',
  24. buttonIcon: 'github',
  25. url,
  26. },
  27. })
  28. expect(view.getByLabelText('GitHub')).toBeInTheDocument()
  29. expect(view.getByIconName('github')).toBeInTheDocument()
  30. })
  31. it('supports default slot', () => {
  32. const view = renderComponent(CommonThirdPartyAuthenticationButton, {
  33. props: {
  34. url,
  35. },
  36. slots: {
  37. default: () => 'GitHub',
  38. },
  39. })
  40. expect(view.getByText('GitHub')).toBeInTheDocument()
  41. })
  42. })