@tebuto/react-booking-widget 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tebuto/react-booking-widget",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "React Component for the Tebuto Booking Widget",
5
5
  "author": "Tebuto GmbH",
6
6
  "homepage": "https://tebuto.de",
@@ -1,62 +0,0 @@
1
- import { render, screen } from '@testing-library/react'
2
- import { TEBUTO_BOOKING_WIDGET_NO_SCRIPT_TEXT, TEBUTO_BOOKING_WIDGET_SCRIPT_URL } from '../constants'
3
- import TebutoBookingWidget from './TebutoBookingWidget'
4
-
5
- describe('TebutoBookingWidget', () => {
6
- const therapistUUID = '9fddab56-5dd5-4bc4-b1bd-3b1d52eb952f'
7
-
8
- it('should add a script tag to load the Tebuto Booking Widget to the page head', () => {
9
- render(<TebutoBookingWidget therapistUUID={therapistUUID} />)
10
-
11
- const container = screen.getByTestId<HTMLDivElement>('tebuto-booking-widget-container')
12
-
13
- expect(container).not.toBeNull()
14
- expect(container.childNodes).toHaveLength(2)
15
-
16
- // @ts-expect-error ts(2339)
17
- expect(container.childNodes[0].attributes['data-testid'].value).toBe('tebuto-booking-widget-script')
18
- // @ts-expect-error ts(2339)
19
- expect(container.childNodes[1].attributes['data-testid'].value).toBe('tebuto-booking-widget-noscript')
20
-
21
- const script = screen.getByTestId<HTMLScriptElement>('tebuto-booking-widget-script')
22
- expect(script).not.toBeNull()
23
- expect(script.src).toBe(TEBUTO_BOOKING_WIDGET_SCRIPT_URL)
24
- expect(script.getAttribute('data-therapist-uuid')).toBe(therapistUUID)
25
-
26
- const noscript = screen.getByTestId('tebuto-booking-widget-noscript')
27
- expect(noscript).not.toBeNull()
28
- expect(noscript.textContent).toBe(TEBUTO_BOOKING_WIDGET_NO_SCRIPT_TEXT)
29
- })
30
-
31
- it('should set the "data-background-color" attribute of the script tag to the value of the "backgroundColor" prop', () => {
32
- const backgroundColor = '#ffffff'
33
- render(<TebutoBookingWidget therapistUUID={therapistUUID} backgroundColor={backgroundColor} />)
34
-
35
- const script = screen.getByTestId('tebuto-booking-widget-script')
36
- expect(script.getAttribute('data-background-color')).toBe(backgroundColor)
37
- })
38
-
39
- it('should set the "data-border" attribute of the script tag to the value of the "border" prop', () => {
40
- const border = false
41
- render(<TebutoBookingWidget therapistUUID={therapistUUID} border={border} />)
42
-
43
- const script = screen.getByTestId('tebuto-booking-widget-script')
44
- expect(script.getAttribute('data-border')).toBe(border.toString())
45
- })
46
-
47
- it('should set the "data-categories" attribute of the script tag to the value of the "categories" prop', () => {
48
- const categories = [1, 2, 3]
49
- render(<TebutoBookingWidget therapistUUID={therapistUUID} categories={categories} />)
50
-
51
- const script = screen.getByTestId('tebuto-booking-widget-script')
52
- expect(script.getAttribute('data-categories')).toBe(categories.join(','))
53
- })
54
-
55
- it('should set the noscript text to the value of the "noScriptText" prop', () => {
56
- const noScriptText = 'This is the noscript text'
57
- render(<TebutoBookingWidget therapistUUID={therapistUUID} noScriptText={noScriptText} />)
58
-
59
- const noscript = screen.getByTestId('tebuto-booking-widget-noscript')
60
- expect(noscript.textContent).toBe(noScriptText)
61
- })
62
- })
@@ -1,29 +0,0 @@
1
- import { JSX } from 'react'
2
- import { TEBUTO_BOOKING_WIDGET_ID, TEBUTO_BOOKING_WIDGET_NO_SCRIPT_TEXT, TEBUTO_BOOKING_WIDGET_SCRIPT_URL } from '../constants'
3
- import { TebutoBookingWidgetConfiguration } from '../types'
4
-
5
- type TebutoBookingWidgetProps = {
6
- noScriptText?: string
7
- } & TebutoBookingWidgetConfiguration
8
-
9
- export default function TebutoBookingWidget({ noScriptText = TEBUTO_BOOKING_WIDGET_NO_SCRIPT_TEXT, ...config }: TebutoBookingWidgetProps): JSX.Element {
10
- return (
11
- <div id={TEBUTO_BOOKING_WIDGET_ID} data-testid="tebuto-booking-widget-container">
12
- <TebutoBookingWidgetScript config={config} />
13
- <noscript data-testid="tebuto-booking-widget-noscript">{noScriptText}</noscript>
14
- </div>
15
- )
16
- }
17
-
18
- function TebutoBookingWidgetScript({ config }: { config: TebutoBookingWidgetConfiguration }): JSX.Element {
19
- return (
20
- <script
21
- src={TEBUTO_BOOKING_WIDGET_SCRIPT_URL}
22
- data-therapist-uuid={config.therapistUUID}
23
- {...(config.backgroundColor ? { 'data-background-color': config.backgroundColor } : {})}
24
- {...(config.categories ? { 'data-categories': config.categories.join(',') } : {})}
25
- {...(config.border !== undefined ? { 'data-border': config.border ? 'true' : 'false' } : {})}
26
- data-testid="tebuto-booking-widget-script"
27
- />
28
- )
29
- }
@@ -1 +0,0 @@
1
- export { default as TebutoBookingWidget } from './TebutoBookingWidget'
package/src/constants.ts DELETED
@@ -1,3 +0,0 @@
1
- export const TEBUTO_BOOKING_WIDGET_SCRIPT_URL = 'https://widget.tebuto.de/booking-widget.js'
2
- export const TEBUTO_BOOKING_WIDGET_ID = 'tebuto-booking-widget'
3
- export const TEBUTO_BOOKING_WIDGET_NO_SCRIPT_TEXT = 'Widget konnte nicht geladen werden. Möglicherweise ist Skripting im Browser deaktiviert.'
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './components'
2
- export * from './types'
package/src/types.ts DELETED
@@ -1,6 +0,0 @@
1
- export type TebutoBookingWidgetConfiguration = {
2
- therapistUUID: string
3
- backgroundColor?: string
4
- categories?: number[]
5
- border?: boolean
6
- }