@atlassian/clientside-extensions-components 2.4.1 → 2.5.0-84fa90d-kwd5ix2w

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.
Files changed (147) hide show
  1. package/dist/cjs/ExtensionPoint.js +4 -4
  2. package/dist/cjs/ExtensionPoint.js.map +1 -1
  3. package/dist/cjs/ExtensionPointInfo.js +8 -8
  4. package/dist/cjs/ExtensionPointInfo.js.map +1 -1
  5. package/dist/cjs/ExtensionsObservable.js +14 -12
  6. package/dist/cjs/ExtensionsObservable.js.map +1 -1
  7. package/dist/cjs/debug/useDebug.js +3 -3
  8. package/dist/cjs/debug/useDebug.js.map +1 -1
  9. package/dist/cjs/debug/useDiscovery.js +3 -3
  10. package/dist/cjs/debug/useDiscovery.js.map +1 -1
  11. package/dist/cjs/debug/useLogging.js +3 -3
  12. package/dist/cjs/debug/useLogging.js.map +1 -1
  13. package/dist/cjs/debug/useValidation.js +3 -3
  14. package/dist/cjs/debug/useValidation.js.map +1 -1
  15. package/dist/cjs/handlers/AsyncPanelHandler.js +10 -9
  16. package/dist/cjs/handlers/AsyncPanelHandler.js.map +1 -1
  17. package/dist/cjs/handlers/ButtonHandler.js +4 -3
  18. package/dist/cjs/handlers/ButtonHandler.js.map +1 -1
  19. package/dist/cjs/handlers/LinkHandler.js +4 -3
  20. package/dist/cjs/handlers/LinkHandler.js.map +1 -1
  21. package/dist/cjs/handlers/ModalHandler.js +16 -14
  22. package/dist/cjs/handlers/ModalHandler.js.map +1 -1
  23. package/dist/cjs/handlers/PanelHandler.js +6 -5
  24. package/dist/cjs/handlers/PanelHandler.js.map +1 -1
  25. package/dist/cjs/handlers/SectionHandler.js +3 -2
  26. package/dist/cjs/handlers/SectionHandler.js.map +1 -1
  27. package/dist/cjs/handlers/index.js +1 -0
  28. package/dist/cjs/handlers/index.js.map +1 -1
  29. package/dist/cjs/index.js +11 -10
  30. package/dist/cjs/index.js.map +1 -1
  31. package/dist/cjs/renderElementAsReact.js +3 -3
  32. package/dist/cjs/renderElementAsReact.js.map +1 -1
  33. package/dist/cjs/styled.js +13 -13
  34. package/dist/cjs/styled.js.map +1 -1
  35. package/dist/cjs/useExtensions.js +18 -14
  36. package/dist/cjs/useExtensions.js.map +1 -1
  37. package/dist/cjs/useWebPanelRenderer.js +4 -4
  38. package/dist/cjs/useWebPanelRenderer.js.map +1 -1
  39. package/dist/esm/ExtensionPointInfo.js.map +1 -1
  40. package/dist/esm/ExtensionsObservable.js.map +1 -1
  41. package/dist/esm/debug/types.js +1 -0
  42. package/dist/esm/handlers/types.js +1 -0
  43. package/dist/esm/renderElementAsReact.js +1 -1
  44. package/dist/esm/renderElementAsReact.js.map +1 -1
  45. package/dist/esm/useWebPanelRenderer.js.map +1 -1
  46. package/dist/types/ExtensionPointInfo.d.ts.map +1 -1
  47. package/dist/types/styled.d.ts +7 -7
  48. package/dist/types/styled.d.ts.map +1 -1
  49. package/lib/ExtensionPointInfo.tsx +1 -0
  50. package/lib/ExtensionsObservable.test.ts +2 -2
  51. package/package.json +12 -11
  52. package/dist/cjs/ExtensionPoint.test.js +0 -96
  53. package/dist/cjs/ExtensionPoint.test.js.map +0 -1
  54. package/dist/cjs/ExtensionPointInfo.test.js +0 -189
  55. package/dist/cjs/ExtensionPointInfo.test.js.map +0 -1
  56. package/dist/cjs/ExtensionsObservable.test.js +0 -349
  57. package/dist/cjs/ExtensionsObservable.test.js.map +0 -1
  58. package/dist/cjs/debug/useDebug.test.js +0 -49
  59. package/dist/cjs/debug/useDebug.test.js.map +0 -1
  60. package/dist/cjs/debug/useDiscovery.test.js +0 -49
  61. package/dist/cjs/debug/useDiscovery.test.js.map +0 -1
  62. package/dist/cjs/debug/useLogging.test.js +0 -49
  63. package/dist/cjs/debug/useLogging.test.js.map +0 -1
  64. package/dist/cjs/debug/useValidation.test.js +0 -49
  65. package/dist/cjs/debug/useValidation.test.js.map +0 -1
  66. package/dist/cjs/handlers/AsyncPanelHandler.test.js +0 -189
  67. package/dist/cjs/handlers/AsyncPanelHandler.test.js.map +0 -1
  68. package/dist/cjs/handlers/ButtonHandler.test.js +0 -40
  69. package/dist/cjs/handlers/ButtonHandler.test.js.map +0 -1
  70. package/dist/cjs/handlers/LinkHandler.test.js +0 -43
  71. package/dist/cjs/handlers/LinkHandler.test.js.map +0 -1
  72. package/dist/cjs/handlers/ModalHandler.test.js +0 -189
  73. package/dist/cjs/handlers/ModalHandler.test.js.map +0 -1
  74. package/dist/cjs/handlers/PanelHandler.test.js +0 -88
  75. package/dist/cjs/handlers/PanelHandler.test.js.map +0 -1
  76. package/dist/cjs/handlers/SectionHandler.test.js +0 -17
  77. package/dist/cjs/handlers/SectionHandler.test.js.map +0 -1
  78. package/dist/cjs/index.test.js +0 -7
  79. package/dist/cjs/index.test.js.map +0 -1
  80. package/dist/cjs/renderElementAsReact.test.js +0 -54
  81. package/dist/cjs/renderElementAsReact.test.js.map +0 -1
  82. package/dist/cjs/useExtensions.test.js +0 -647
  83. package/dist/cjs/useExtensions.test.js.map +0 -1
  84. package/dist/esm/ExtensionPoint.test.js +0 -93
  85. package/dist/esm/ExtensionPoint.test.js.map +0 -1
  86. package/dist/esm/ExtensionPointInfo.test.js +0 -186
  87. package/dist/esm/ExtensionPointInfo.test.js.map +0 -1
  88. package/dist/esm/ExtensionsObservable.test.js +0 -346
  89. package/dist/esm/ExtensionsObservable.test.js.map +0 -1
  90. package/dist/esm/debug/useDebug.test.js +0 -46
  91. package/dist/esm/debug/useDebug.test.js.map +0 -1
  92. package/dist/esm/debug/useDiscovery.test.js +0 -46
  93. package/dist/esm/debug/useDiscovery.test.js.map +0 -1
  94. package/dist/esm/debug/useLogging.test.js +0 -46
  95. package/dist/esm/debug/useLogging.test.js.map +0 -1
  96. package/dist/esm/debug/useValidation.test.js +0 -46
  97. package/dist/esm/debug/useValidation.test.js.map +0 -1
  98. package/dist/esm/handlers/AsyncPanelHandler.test.js +0 -186
  99. package/dist/esm/handlers/AsyncPanelHandler.test.js.map +0 -1
  100. package/dist/esm/handlers/ButtonHandler.test.js +0 -37
  101. package/dist/esm/handlers/ButtonHandler.test.js.map +0 -1
  102. package/dist/esm/handlers/LinkHandler.test.js +0 -40
  103. package/dist/esm/handlers/LinkHandler.test.js.map +0 -1
  104. package/dist/esm/handlers/ModalHandler.test.js +0 -186
  105. package/dist/esm/handlers/ModalHandler.test.js.map +0 -1
  106. package/dist/esm/handlers/PanelHandler.test.js +0 -85
  107. package/dist/esm/handlers/PanelHandler.test.js.map +0 -1
  108. package/dist/esm/handlers/SectionHandler.test.js +0 -14
  109. package/dist/esm/handlers/SectionHandler.test.js.map +0 -1
  110. package/dist/esm/index.test.js +0 -7
  111. package/dist/esm/index.test.js.map +0 -1
  112. package/dist/esm/renderElementAsReact.test.js +0 -51
  113. package/dist/esm/renderElementAsReact.test.js.map +0 -1
  114. package/dist/esm/useExtensions.test.js +0 -644
  115. package/dist/esm/useExtensions.test.js.map +0 -1
  116. package/dist/types/ExtensionPoint.test.d.ts +0 -2
  117. package/dist/types/ExtensionPoint.test.d.ts.map +0 -1
  118. package/dist/types/ExtensionPointInfo.test.d.ts +0 -2
  119. package/dist/types/ExtensionPointInfo.test.d.ts.map +0 -1
  120. package/dist/types/ExtensionsObservable.test.d.ts +0 -2
  121. package/dist/types/ExtensionsObservable.test.d.ts.map +0 -1
  122. package/dist/types/debug/useDebug.test.d.ts +0 -2
  123. package/dist/types/debug/useDebug.test.d.ts.map +0 -1
  124. package/dist/types/debug/useDiscovery.test.d.ts +0 -2
  125. package/dist/types/debug/useDiscovery.test.d.ts.map +0 -1
  126. package/dist/types/debug/useLogging.test.d.ts +0 -2
  127. package/dist/types/debug/useLogging.test.d.ts.map +0 -1
  128. package/dist/types/debug/useValidation.test.d.ts +0 -2
  129. package/dist/types/debug/useValidation.test.d.ts.map +0 -1
  130. package/dist/types/handlers/AsyncPanelHandler.test.d.ts +0 -2
  131. package/dist/types/handlers/AsyncPanelHandler.test.d.ts.map +0 -1
  132. package/dist/types/handlers/ButtonHandler.test.d.ts +0 -2
  133. package/dist/types/handlers/ButtonHandler.test.d.ts.map +0 -1
  134. package/dist/types/handlers/LinkHandler.test.d.ts +0 -2
  135. package/dist/types/handlers/LinkHandler.test.d.ts.map +0 -1
  136. package/dist/types/handlers/ModalHandler.test.d.ts +0 -2
  137. package/dist/types/handlers/ModalHandler.test.d.ts.map +0 -1
  138. package/dist/types/handlers/PanelHandler.test.d.ts +0 -2
  139. package/dist/types/handlers/PanelHandler.test.d.ts.map +0 -1
  140. package/dist/types/handlers/SectionHandler.test.d.ts +0 -2
  141. package/dist/types/handlers/SectionHandler.test.d.ts.map +0 -1
  142. package/dist/types/index.test.d.ts +0 -1
  143. package/dist/types/index.test.d.ts.map +0 -1
  144. package/dist/types/renderElementAsReact.test.d.ts +0 -2
  145. package/dist/types/renderElementAsReact.test.d.ts.map +0 -1
  146. package/dist/types/useExtensions.test.d.ts +0 -2
  147. package/dist/types/useExtensions.test.d.ts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExtensionsObservable.test.js","sourceRoot":"","sources":["../../lib/ExtensionsObservable.test.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AACvC,uHAAiE;AACjE,sFAAgE;AAIhE,iEAA+F;AAG/F,IAAI,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;AAEvD,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAC9B,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC5B,sDAAsD;AACtD,gDAAgD;AAChD,KAAK,CAAC,wBAAwB,EAAE,CAAC;AASjC,SAAS,0BAA0B;IAC/B,IAAI,gBAAsC,CAAC;IAC3C,cAAM,CAAC,wCAAQ,CAAC,WAAW,CAAC,CAAC,SAAS,EAAE,CAAC;IACzC,cAAM,CAAC,wCAAQ,CAAC,WAAW,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;QACnD,SAAS,EAAE,CAAC,QAAQ,EA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AAE,KAAK,EAAE,CAAC,CAAC;QAEnG,MAAM,CAAC,WAAW,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { mocked } from 'ts-jest/utils';\nimport registry from '@atlassian/clientside-extensions-registry';\nimport * as debug from '@atlassian/clientside-extensions-debug';\nimport type { ExtensionAPI, ExtensionDescriptor } from '@atlassian/clientside-extensions-registry';\n\nimport type { ExtensionPointUpdate, Options } from './types';\nimport { getExtensionPointSubscription, getValidatedExtensions } from './ExtensionsObservable';\nimport Mock = jest.Mock;\n\njest.mock('@atlassian/clientside-extensions-registry');\n\ndebug.setLoggingEnabled(true);\ndebug.setDebugEnabled(true);\n// avoid spamming the console with error/warn messages\n// eslint-disable-next-line no-underscore-dangle\ndebug._deregisterDefaultLogger();\n\ntype MockSubjectPayload = {\n descriptors: ExtensionDescriptor[];\n loadingState: boolean;\n};\n\ntype MockLocationObserver = (payload: MockSubjectPayload) => void;\n\nfunction createMockLocationObserver(): MockLocationObserver {\n let locationObserver: MockLocationObserver;\n mocked(registry.getLocation).mockClear();\n mocked(registry.getLocation).mockImplementation(() => ({\n subscribe: (observer) => {\n locationObserver = observer;\n return {\n unsubscribe: () => {},\n };\n },\n }));\n\n return (payload) => locationObserver(payload);\n}\n\nconst supportedExtension: ExtensionDescriptor = {\n key: 'fake-1',\n location: 'fake-location',\n weight: 10,\n attributes: { label: 'a fake label' },\n attributesProvider: () => ({ type: 'button' }),\n};\nconst unsupportedExtension: ExtensionDescriptor = {\n key: 'fake-2',\n location: 'fake-location',\n weight: 10,\n attributes: { label: 'a fake label' },\n};\n\nconst LOCATION = 'fake-location';\n\ndescribe('getExtensionPointSubscription', () => {\n const onDebugSpy = jest.fn();\n debug.observeLogger(onDebugSpy);\n let locationObserver: MockLocationObserver;\n\n beforeEach(() => {\n onDebugSpy.mockClear();\n locationObserver = createMockLocationObserver();\n });\n\n it('should return an observable', () => {\n const observable = getExtensionPointSubscription(LOCATION, null);\n\n expect(observable.subscribe).toBeInstanceOf(Function);\n });\n\n it('should allow to subscribe to updates', () => {\n const observerSpy = jest.fn();\n getExtensionPointSubscription(LOCATION, null).subscribe(observerSpy);\n locationObserver({ descriptors: [], loadingState: true });\n\n expect(observerSpy).toBeCalled();\n });\n\n it('should allow to unsubscribe from updates again', () => {\n const observerSpy = jest.fn();\n const { unsubscribe } = getExtensionPointSubscription(LOCATION, null).subscribe(observerSpy);\n locationObserver({ descriptors: [], loadingState: true });\n unsubscribe();\n locationObserver({ descriptors: [], loadingState: false });\n\n expect(observerSpy).toBeCalledTimes(1);\n });\n\n it('should notify the observer of registered extensions', () => {\n const observerSpy = jest.fn();\n getExtensionPointSubscription(LOCATION, null).subscribe(observerSpy);\n locationObserver({ descriptors: [supportedExtension], loadingState: false });\n\n expect(observerSpy).toBeCalled();\n expect(observerSpy.mock.calls[0][0]).toBeTruthy();\n const { descriptors, loadingState } = observerSpy.mock.calls[0][0].state;\n expect(descriptors.length).toBe(1);\n expect(loadingState).toBe(false);\n });\n\n it('should only provide descriptors to observer once loading is over', () => {\n const observerSpy = jest.fn();\n getExtensionPointSubscription(LOCATION, null).subscribe(observerSpy);\n\n locationObserver({ descriptors: [], loadingState: true });\n locationObserver({ descriptors: [supportedExtension, unsupportedExtension], loadingState: true });\n locationObserver({ descriptors: [supportedExtension, unsupportedExtension], loadingState: false });\n\n expect(observerSpy).toBeCalledTimes(3);\n\n // first call\n const argFirst = observerSpy.mock.calls[0][0] as ExtensionPointUpdate;\n const { descriptors: descriptorsFirst, loadingState: loadingFirst } = argFirst.state;\n expect(descriptorsFirst.length).toBe(0);\n expect(loadingFirst).toBe(true);\n\n // second call\n const argSecond = observerSpy.mock.calls[1][0] as ExtensionPointUpdate;\n const { descriptors: descriptorsSecond, loadingState: loadingSecond } = argSecond.state;\n expect(descriptorsSecond.length).toBe(0);\n expect(loadingSecond).toBe(true);\n\n // third call\n const argThird = observerSpy.mock.calls[2][0] as ExtensionPointUpdate;\n const { descriptors: descriptorsThird, loadingState: loadingThird } = argThird.state;\n expect(descriptorsThird.length).toBe(2);\n expect(loadingThird).toBe(false);\n expect(descriptorsThird[0].key).toBe(supportedExtension.key);\n expect(descriptorsThird[1].key).toBe(unsupportedExtension.key);\n });\n\n it('should provide registered extensions with the provided context', () => {\n const someContext = { foo: 'bar' };\n const attributeProviderSpy = jest.fn();\n getExtensionPointSubscription(LOCATION, someContext);\n\n locationObserver({\n descriptors: [\n {\n key: 'fake-1',\n location: LOCATION,\n weight: 10,\n attributes: { label: 'a fake label' },\n attributesProvider: attributeProviderSpy,\n },\n ],\n loadingState: false,\n });\n\n expect(attributeProviderSpy).toBeCalledTimes(1);\n expect(attributeProviderSpy.mock.calls[0][1]).toBe(someContext);\n });\n\n it('should update if a new extension is registered', () => {\n const observerSpy = jest.fn();\n getExtensionPointSubscription(LOCATION, null).subscribe(observerSpy);\n\n locationObserver({ descriptors: [], loadingState: false });\n locationObserver({ descriptors: [supportedExtension], loadingState: false });\n locationObserver({ descriptors: [supportedExtension, unsupportedExtension], loadingState: false });\n\n expect(observerSpy).toBeCalledTimes(3);\n\n // first call\n const argFirst = observerSpy.mock.calls[0][0] as ExtensionPointUpdate;\n const { descriptors: descriptorsFirst } = argFirst.state;\n expect(descriptorsFirst.length).toBe(0);\n\n // second call\n const argSecond = observerSpy.mock.calls[1][0] as ExtensionPointUpdate;\n const { descriptors: descriptorsSecond } = argSecond.state;\n expect(descriptorsSecond.length).toBe(1);\n\n // third call\n const argThird = observerSpy.mock.calls[2][0] as ExtensionPointUpdate;\n const { descriptors: descriptorsThird } = argThird.state;\n expect(descriptorsThird.length).toBe(2);\n });\n\n it('should update if an extension updates its attributes', async () => {\n expect.assertions(5);\n const observerSpy = jest.fn();\n getExtensionPointSubscription(LOCATION, null).subscribe(observerSpy);\n\n let apiReference: ExtensionAPI | undefined;\n\n const selfUpdatingExtension = {\n key: 'updating-extension',\n location: LOCATION,\n weight: 230,\n attributes: { label: 'a fake label', type: 'button' },\n attributesProvider: (api: ExtensionAPI) => {\n apiReference = api;\n return {};\n },\n };\n\n locationObserver({ descriptors: [supportedExtension, unsupportedExtension, selfUpdatingExtension], loadingState: false });\n\n expect(observerSpy).toBeCalled();\n observerSpy.mockClear();\n\n (apiReference as ExtensionAPI).updateAttributes({ foo: 'bar' });\n\n // wait for the update to go through which is a tick away\n await new Promise((resolve) => {\n setTimeout(() => {\n expect(observerSpy).toBeCalled();\n const { update } = observerSpy.mock.calls[0][0];\n expect(update.length).toBe(1);\n expect(update[0].key).toBe('updating-extension');\n expect(update[0].attributes.foo).toBe('bar');\n resolve();\n }, 50);\n });\n });\n\n it('should batch updates together', async () => {\n expect.assertions(8);\n const observerSpy = jest.fn();\n getExtensionPointSubscription(LOCATION, null).subscribe(observerSpy);\n\n let apiReference1: ExtensionAPI | undefined;\n const selfUpdatingExtension1 = {\n key: 'updating-extension-1',\n location: LOCATION,\n weight: 230,\n attributes: { label: 'a fake label', type: 'button' },\n attributesProvider: (api: ExtensionAPI) => {\n apiReference1 = api;\n return {};\n },\n };\n\n let apiReference2: ExtensionAPI | undefined;\n const selfUpdatingExtension2 = {\n key: 'updating-extension-2',\n location: LOCATION,\n weight: 230,\n attributes: { label: 'a fake label', type: 'button' },\n attributesProvider: (api: ExtensionAPI) => {\n apiReference2 = api;\n return {};\n },\n };\n\n locationObserver({ descriptors: [selfUpdatingExtension1, selfUpdatingExtension2], loadingState: false });\n\n observerSpy.mockClear();\n\n (apiReference1 as ExtensionAPI).updateAttributes({ foo: 'bar' });\n (apiReference2 as ExtensionAPI).updateAttributes({ foo: 'bar' });\n\n (apiReference1 as ExtensionAPI).updateAttributes({ foo: 'foo of 1' });\n (apiReference2 as ExtensionAPI).updateAttributes({ foo: 'foo of 2' });\n\n // wait for the update to go through which is a tick away\n await new Promise((resolve) => {\n setTimeout(() => {\n expect(observerSpy).toBeCalledTimes(1);\n const { update } = observerSpy.mock.calls[0][0];\n expect(update.length).toBe(2);\n\n expect(update[0].key).toBe('updating-extension-1');\n expect(update[0].attributes.foo).toBe('foo of 1');\n expect(update[0].attributes.foo).toBe('foo of 1');\n\n expect(update[1].key).toBe('updating-extension-2');\n expect(update[1].attributes.foo).toBe('foo of 2');\n expect(update[1].attributes.foo).toBe('foo of 2');\n resolve();\n }, 50);\n });\n });\n});\n\ndescribe('getValidatedExtensions', () => {\n const onDebugSpy = jest.fn();\n const context = { foo: 'bar' };\n\n debug.observeLogger(onDebugSpy);\n\n let locationObserver: MockLocationObserver;\n let contextValidatorSpy: Mock;\n let attributeValidatorSpy: Mock;\n\n beforeEach(() => {\n onDebugSpy.mockClear();\n locationObserver = createMockLocationObserver();\n contextValidatorSpy = jest.fn().mockReturnValue({ errors: [], warnings: [] });\n attributeValidatorSpy = jest.fn().mockReturnValue({ errors: [], warnings: [] });\n });\n\n it('should not validate the context if no context is specified', () => {\n getValidatedExtensions(LOCATION, null, {\n contextValidator: contextValidatorSpy,\n attributeValidator: attributeValidatorSpy,\n } as Options);\n\n expect(contextValidatorSpy).not.toBeCalled();\n });\n\n it('should validate the context if a context is specified', () => {\n getValidatedExtensions(LOCATION, context, {\n contextValidator: contextValidatorSpy,\n attributeValidator: attributeValidatorSpy,\n });\n\n expect(contextValidatorSpy).toBeCalled();\n expect(contextValidatorSpy.mock.calls[0][0]).toBe(context);\n });\n\n it('should throw an error if the context validation fails', () => {\n expect(() =>\n getValidatedExtensions(LOCATION, context, {\n contextValidator: contextValidatorSpy.mockReturnValue({\n errors: ['some error'],\n warnings: [],\n }),\n attributeValidator: attributeValidatorSpy,\n }),\n ).toThrow(`The context provided for extension-location \"fake-location\" does not match the schema`);\n });\n\n it('should not throw an error if the context validation has warnings', () => {\n expect(() =>\n getValidatedExtensions(LOCATION, context, {\n contextValidator: contextValidatorSpy.mockReturnValue({\n errors: [],\n warnings: ['some warning'],\n }),\n attributeValidator: attributeValidatorSpy,\n }),\n ).not.toThrow();\n });\n\n it('should return an observable', () => {\n const observable = getValidatedExtensions(LOCATION, context, {\n contextValidator: contextValidatorSpy,\n attributeValidator: attributeValidatorSpy,\n });\n\n expect(observable.subscribe).toBeInstanceOf(Function);\n });\n\n it('should allow to subscribe to updates', () => {\n const observerSpy = jest.fn();\n getValidatedExtensions(LOCATION, context, {\n contextValidator: contextValidatorSpy,\n attributeValidator: attributeValidatorSpy,\n }).subscribe(observerSpy);\n locationObserver({ descriptors: [], loadingState: true });\n\n expect(observerSpy).toBeCalled();\n });\n\n it('should allow to unsubscribe from updates again', () => {\n const observerSpy = jest.fn();\n const { unsubscribe } = getValidatedExtensions(LOCATION, context, {\n contextValidator: contextValidatorSpy,\n attributeValidator: attributeValidatorSpy,\n }).subscribe(observerSpy);\n locationObserver({ descriptors: [], loadingState: true });\n locationObserver({ descriptors: [], loadingState: false });\n unsubscribe();\n locationObserver({ descriptors: [supportedExtension], loadingState: false });\n\n expect(observerSpy).toBeCalledTimes(2);\n });\n\n it('should call attributeValidatorSpy with extension attributes', () => {\n const observerSpy = jest.fn();\n getValidatedExtensions(LOCATION, context, {\n contextValidator: contextValidatorSpy,\n attributeValidator: attributeValidatorSpy,\n }).subscribe(observerSpy);\n locationObserver({ descriptors: [supportedExtension], loadingState: false });\n\n expect(attributeValidatorSpy).toBeCalledTimes(1);\n expect(attributeValidatorSpy.mock.calls[0][0]).toStrictEqual({\n ...supportedExtension.attributes,\n ...supportedExtension.attributesProvider!({} as ExtensionAPI, null),\n });\n });\n\n it('should declare all extensions as valid if validator always return \"ok\"', () => {\n const observerSpy = jest.fn();\n getValidatedExtensions(LOCATION, context, {\n contextValidator: contextValidatorSpy,\n attributeValidator: attributeValidatorSpy.mockReturnValue({ errors: [], warnings: [] }),\n }).subscribe(observerSpy);\n locationObserver({ descriptors: [supportedExtension, unsupportedExtension], loadingState: false });\n\n expect(observerSpy).toBeCalledTimes(1);\n const [supported, unsupported] = observerSpy.mock.calls[0][0];\n expect(supported.length).toBe(2);\n expect(unsupported.length).toBe(0);\n });\n\n it('should move extensions into \"unsupported\" if validation fails', () => {\n const observerSpy = jest.fn();\n getValidatedExtensions(LOCATION, context, {\n contextValidator: contextValidatorSpy,\n attributeValidator: attributeValidatorSpy\n .mockReturnValueOnce({ errors: [], warnings: [] })\n .mockReturnValueOnce({ errors: ['some error'], warnings: [] }),\n }).subscribe(observerSpy);\n locationObserver({ descriptors: [supportedExtension, unsupportedExtension], loadingState: false });\n\n expect(observerSpy).toBeCalledTimes(1);\n\n const [supported, unsupported] = observerSpy.mock.calls[0][0];\n expect(supported.length).toBe(1);\n expect(supported[0].key).toBe(supportedExtension.key);\n\n expect(unsupported.length).toBe(1);\n expect(unsupported[0].key).toBe(unsupportedExtension.key);\n });\n\n it('should declare all extensions as valid if validator has any warnings', () => {\n const observerSpy = jest.fn();\n getValidatedExtensions(LOCATION, context, {\n contextValidator: contextValidatorSpy,\n attributeValidator: attributeValidatorSpy.mockReturnValue({ errors: [], warnings: ['some warning'] }),\n }).subscribe(observerSpy);\n locationObserver({ descriptors: [supportedExtension, unsupportedExtension], loadingState: false });\n\n expect(observerSpy).toBeCalledTimes(1);\n const [supported, unsupported] = observerSpy.mock.calls[0][0];\n expect(supported.length).toBe(2);\n expect(unsupported.length).toBe(0);\n });\n});\n"]}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const utils_1 = require("ts-jest/utils");
5
- const react_hooks_1 = require("@testing-library/react-hooks");
6
- const clientside_extensions_debug_1 = require("@atlassian/clientside-extensions-debug");
7
- const useDebug_1 = tslib_1.__importDefault(require("./useDebug"));
8
- jest.mock('@atlassian/clientside-extensions-debug');
9
- describe('useDebug hook', () => {
10
- beforeEach(() => {
11
- utils_1.mocked(clientside_extensions_debug_1.isDebugEnabled).mockClear();
12
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockClear();
13
- });
14
- it('should return the current state of the debug state', () => {
15
- const INITIAL_VALUE = false;
16
- utils_1.mocked(clientside_extensions_debug_1.isDebugEnabled).mockReturnValueOnce(INITIAL_VALUE);
17
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockReturnValueOnce({ unsubscribe() { } });
18
- const { result } = react_hooks_1.renderHook(() => useDebug_1.default());
19
- const [debugValue] = result.current;
20
- expect(debugValue).toBe(INITIAL_VALUE);
21
- });
22
- it('should react to changes to the discover debug setting', () => {
23
- const INITIAL_VALUE = true;
24
- const CHANGED_BOOLEAN_VALUE = false;
25
- let updateCallback;
26
- utils_1.mocked(clientside_extensions_debug_1.isDebugEnabled).mockReturnValueOnce(INITIAL_VALUE);
27
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockImplementation((expectedCallback) => {
28
- updateCallback = expectedCallback;
29
- return {
30
- unsubscribe() { },
31
- };
32
- });
33
- const { result } = react_hooks_1.renderHook(() => useDebug_1.default());
34
- let [debugValue] = result.current;
35
- expect(debugValue).toBe(INITIAL_VALUE);
36
- react_hooks_1.act(() => {
37
- updateCallback({
38
- discovery: CHANGED_BOOLEAN_VALUE,
39
- debug: CHANGED_BOOLEAN_VALUE,
40
- logging: CHANGED_BOOLEAN_VALUE,
41
- validation: CHANGED_BOOLEAN_VALUE,
42
- logLevel: clientside_extensions_debug_1.LogLevel.warn,
43
- });
44
- });
45
- [debugValue] = result.current;
46
- expect(debugValue).toBe(CHANGED_BOOLEAN_VALUE);
47
- });
48
- });
49
- //# sourceMappingURL=useDebug.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDebug.test.js","sourceRoot":"","sources":["../../../lib/debug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N,CAAC,CAAC,CAAC;QAEH,MAAM,EAAE,MAAM,EAAE,GAAG,wBAAU,CAAC,GAAG,EAAE,CAAC,kBAAQ,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;QAElC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEvC,iBAAG,CAAC,GAAG,EAAE;YACL,cAAc,CAAC;gBACX,SAAS,EAAE,qBAAqB;gBAChC,KAAK,EAAE,qBAAqB;gBAC5B,OAAO,EAAE,qBAAqB;gBAC9B,UAAU,EAAE,qBAAqB;gBACjC,QAAQ,EAAE,sCAAQ,CAAC,IAAI;aAC1B,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;QAE9B,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { mocked } from 'ts-jest/utils';\nimport { act, renderHook } from '@testing-library/react-hooks';\nimport { isDebugEnabled, LogLevel, observeStateChange } from '@atlassian/clientside-extensions-debug';\nimport useDebug from './useDebug';\n\njest.mock('@atlassian/clientside-extensions-debug');\n\ndescribe('useDebug hook', () => {\n beforeEach(() => {\n mocked(isDebugEnabled).mockClear();\n mocked(observeStateChange).mockClear();\n });\n\n it('should return the current state of the debug state', () => {\n const INITIAL_VALUE = false;\n mocked(isDebugEnabled).mockReturnValueOnce(INITIAL_VALUE);\n mocked(observeStateChange).mockReturnValueOnce({ unsubscribe() {} });\n\n const { result } = renderHook(() => useDebug());\n const [debugValue] = result.current;\n\n expect(debugValue).toBe(INITIAL_VALUE);\n });\n\n it('should react to changes to the discover debug setting', () => {\n const INITIAL_VALUE = true;\n const CHANGED_BOOLEAN_VALUE = false;\n\n let updateCallback: Parameters<typeof observeStateChange>[0];\n mocked(isDebugEnabled).mockReturnValueOnce(INITIAL_VALUE);\n mocked(observeStateChange).mockImplementation((expectedCallback) => {\n updateCallback = expectedCallback;\n return {\n unsubscribe() {},\n };\n });\n\n const { result } = renderHook(() => useDebug());\n let [debugValue] = result.current;\n\n expect(debugValue).toBe(INITIAL_VALUE);\n\n act(() => {\n updateCallback({\n discovery: CHANGED_BOOLEAN_VALUE,\n debug: CHANGED_BOOLEAN_VALUE,\n logging: CHANGED_BOOLEAN_VALUE,\n validation: CHANGED_BOOLEAN_VALUE,\n logLevel: LogLevel.warn,\n });\n });\n\n [debugValue] = result.current;\n\n expect(debugValue).toBe(CHANGED_BOOLEAN_VALUE);\n });\n});\n"]}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const utils_1 = require("ts-jest/utils");
5
- const react_hooks_1 = require("@testing-library/react-hooks");
6
- const clientside_extensions_debug_1 = require("@atlassian/clientside-extensions-debug");
7
- const useDiscovery_1 = tslib_1.__importDefault(require("./useDiscovery"));
8
- jest.mock('@atlassian/clientside-extensions-debug');
9
- describe('useDiscovery hook', () => {
10
- beforeEach(() => {
11
- utils_1.mocked(clientside_extensions_debug_1.isDiscoveryEnabled).mockClear();
12
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockClear();
13
- });
14
- it('should return the current state of the discover debug setting', () => {
15
- const INITIAL_VALUE = false;
16
- utils_1.mocked(clientside_extensions_debug_1.isDiscoveryEnabled).mockReturnValueOnce(INITIAL_VALUE);
17
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockReturnValueOnce({ unsubscribe() { } });
18
- const { result } = react_hooks_1.renderHook(() => useDiscovery_1.default());
19
- const [discoveryValue] = result.current;
20
- expect(discoveryValue).toBe(INITIAL_VALUE);
21
- });
22
- it('should react to changes to the discover debug setting', () => {
23
- const INITIAL_VALUE = true;
24
- const CHANGED_BOOLEAN_VALUE = false;
25
- let updateCallback;
26
- utils_1.mocked(clientside_extensions_debug_1.isDiscoveryEnabled).mockReturnValueOnce(INITIAL_VALUE);
27
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockImplementation((expectedCallback) => {
28
- updateCallback = expectedCallback;
29
- return {
30
- unsubscribe() { },
31
- };
32
- });
33
- const { result } = react_hooks_1.renderHook(() => useDiscovery_1.default());
34
- let [discoveryValue] = result.current;
35
- expect(discoveryValue).toBe(INITIAL_VALUE);
36
- react_hooks_1.act(() => {
37
- updateCallback({
38
- discovery: CHANGED_BOOLEAN_VALUE,
39
- debug: CHANGED_BOOLEAN_VALUE,
40
- logging: CHANGED_BOOLEAN_VALUE,
41
- validation: CHANGED_BOOLEAN_VALUE,
42
- logLevel: clientside_extensions_debug_1.LogLevel.warn,
43
- });
44
- });
45
- [discoveryValue] = result.current;
46
- expect(discoveryValue).toBe(CHANGED_BOOLEAN_VALUE);
47
- });
48
- });
49
- //# sourceMappingURL=useDiscovery.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDiscovery.test.js","sourceRoot":"","sources":["../../../lib/debug/useDiscovery.test.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AACvC,8DAA+D;AAC/D,wFAA0G;AAC1G,0EAA0C;AAE1C,IAAI,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;AAEpD,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC/B,UAAU,CAAC,GAAG,EAAE;QACZ,cAAM,CAAC,gDAAkB,CAAC,CAAC,SAAS,EAAE,CAAC;QACvC,cAAM,CAAC,gDAAkB,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACrE,MAAM,aAAa,GAAG,KAAK,CAAC;QAC5B,cAAM,CAAC,gDAAkB,CAAC,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAC9D,cAAM,CAAC,gDAAkB,CAAC,CAAC,mBAAmB,C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,cAAc,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { mocked } from 'ts-jest/utils';\nimport { act, renderHook } from '@testing-library/react-hooks';\nimport { isDiscoveryEnabled, LogLevel, observeStateChange } from '@atlassian/clientside-extensions-debug';\nimport useDiscovery from './useDiscovery';\n\njest.mock('@atlassian/clientside-extensions-debug');\n\ndescribe('useDiscovery hook', () => {\n beforeEach(() => {\n mocked(isDiscoveryEnabled).mockClear();\n mocked(observeStateChange).mockClear();\n });\n\n it('should return the current state of the discover debug setting', () => {\n const INITIAL_VALUE = false;\n mocked(isDiscoveryEnabled).mockReturnValueOnce(INITIAL_VALUE);\n mocked(observeStateChange).mockReturnValueOnce({ unsubscribe() {} });\n\n const { result } = renderHook(() => useDiscovery());\n const [discoveryValue] = result.current;\n\n expect(discoveryValue).toBe(INITIAL_VALUE);\n });\n\n it('should react to changes to the discover debug setting', () => {\n const INITIAL_VALUE = true;\n const CHANGED_BOOLEAN_VALUE = false;\n\n let updateCallback: Parameters<typeof observeStateChange>[0];\n mocked(isDiscoveryEnabled).mockReturnValueOnce(INITIAL_VALUE);\n mocked(observeStateChange).mockImplementation((expectedCallback) => {\n updateCallback = expectedCallback;\n return {\n unsubscribe() {},\n };\n });\n\n const { result } = renderHook(() => useDiscovery());\n let [discoveryValue] = result.current;\n\n expect(discoveryValue).toBe(INITIAL_VALUE);\n\n act(() => {\n updateCallback({\n discovery: CHANGED_BOOLEAN_VALUE,\n debug: CHANGED_BOOLEAN_VALUE,\n logging: CHANGED_BOOLEAN_VALUE,\n validation: CHANGED_BOOLEAN_VALUE,\n logLevel: LogLevel.warn,\n });\n });\n\n [discoveryValue] = result.current;\n\n expect(discoveryValue).toBe(CHANGED_BOOLEAN_VALUE);\n });\n});\n"]}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const utils_1 = require("ts-jest/utils");
5
- const react_hooks_1 = require("@testing-library/react-hooks");
6
- const clientside_extensions_debug_1 = require("@atlassian/clientside-extensions-debug");
7
- const useLogging_1 = tslib_1.__importDefault(require("./useLogging"));
8
- jest.mock('@atlassian/clientside-extensions-debug');
9
- describe('useLogging hook', () => {
10
- beforeEach(() => {
11
- utils_1.mocked(clientside_extensions_debug_1.isLoggingEnabled).mockClear();
12
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockClear();
13
- });
14
- it('should return the current state of the logging debug setting', () => {
15
- const INITIAL_VALUE = false;
16
- utils_1.mocked(clientside_extensions_debug_1.isLoggingEnabled).mockReturnValueOnce(INITIAL_VALUE);
17
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockReturnValueOnce({ unsubscribe() { } });
18
- const { result } = react_hooks_1.renderHook(() => useLogging_1.default());
19
- const [loggingValue] = result.current;
20
- expect(loggingValue).toBe(INITIAL_VALUE);
21
- });
22
- it('should react to changes to the logging debug setting', () => {
23
- const INITIAL_VALUE = true;
24
- const CHANGED_BOOLEAN_VALUE = false;
25
- let updateCallback;
26
- utils_1.mocked(clientside_extensions_debug_1.isLoggingEnabled).mockReturnValueOnce(INITIAL_VALUE);
27
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockImplementation((expectedCallback) => {
28
- updateCallback = expectedCallback;
29
- return {
30
- unsubscribe() { },
31
- };
32
- });
33
- const { result } = react_hooks_1.renderHook(() => useLogging_1.default());
34
- let [loggingValue] = result.current;
35
- expect(loggingValue).toBe(INITIAL_VALUE);
36
- react_hooks_1.act(() => {
37
- updateCallback({
38
- discovery: CHANGED_BOOLEAN_VALUE,
39
- debug: CHANGED_BOOLEAN_VALUE,
40
- logging: CHANGED_BOOLEAN_VALUE,
41
- validation: CHANGED_BOOLEAN_VALUE,
42
- logLevel: clientside_extensions_debug_1.LogLevel.warn,
43
- });
44
- });
45
- [loggingValue] = result.current;
46
- expect(loggingValue).toBe(CHANGED_BOOLEAN_VALUE);
47
- });
48
- });
49
- //# sourceMappingURL=useLogging.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLogging.test.js","sourceRoot":"","sources":["../../../lib/debug/useLogging.test.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AACvC,8DAA+D;AAC/D,wFAAwG;AACxG,sEAAsC;AAEtC,IAAI,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,UAAU,CAAC,GAAG,EAAE;QACZ,cAAM,CAAC,8CAAgB,CAAC,CAAC,SAAS,EAAE,CAAC;QACrC,cAAM,CAAC,gDAAkB,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACpE,MAAM,aAAa,GAAG,KAAK,CAAC;QAC5B,cAAM,CAAC,8CAAgB,CAAC,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAC5D,cAAM,CAAC,gDAAkB,CAAC,CAAC,mBAAmB,CAAC,EAAE,WAAW,KAAI,CAAC,EAAE,CAAC,CAAC;QAErE,MAAM,EAAE,MAAM,EAAE,GAAG,wBAAU,CAAC,GAAG,EAAE,CAAC,oBAAU,EAAE,CAAC,CAAC;QAClD,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;QAEtC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC5D,MAAM,aAAa,GAAG,IAAI,CAAC;QAC3B,MAAM,qBAAqB,GAAG,KAAK,CAAC;QAEpC,IAAI,cAAwD,CAAC;QAC7D,cAAM,CAAC,8CAAgB,CAAC,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAC5D,cAAM,CAAC,gDAAkB,CAAC,CAAC,kBAAkB,CAAC,CAAC,gBAAgB,EAAE,EAAE;YAC/D,cAAc,GAAG,gBAAgB,CAAC;YAClC,OAAO;gBACH,WAAW,KAAI,CAAC;aACnB,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,MAAM,EAAE,MAAM,EAAE,GAAG,wBAAU,CAAC,GAAG,EAAE,CAAC,oBAAU,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;QAEpC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEzC,iBAAG,CAAC,GAAG,EAAE;YACL,cAAc,CAAC;gBACX,SAAS,EAAE,qBAAqB;gBAChC,KAAK,EAAE,qBAAqB;gBAC5B,OAAO,EAAE,qBAAqB;gBAC9B,UAAU,EAAE,qBAAqB;gBACjC,QAAQ,EAAE,sCAAQ,CAAC,IAAI;aAC1B,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;QAEhC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { mocked } from 'ts-jest/utils';\nimport { act, renderHook } from '@testing-library/react-hooks';\nimport { isLoggingEnabled, LogLevel, observeStateChange } from '@atlassian/clientside-extensions-debug';\nimport useLogging from './useLogging';\n\njest.mock('@atlassian/clientside-extensions-debug');\n\ndescribe('useLogging hook', () => {\n beforeEach(() => {\n mocked(isLoggingEnabled).mockClear();\n mocked(observeStateChange).mockClear();\n });\n\n it('should return the current state of the logging debug setting', () => {\n const INITIAL_VALUE = false;\n mocked(isLoggingEnabled).mockReturnValueOnce(INITIAL_VALUE);\n mocked(observeStateChange).mockReturnValueOnce({ unsubscribe() {} });\n\n const { result } = renderHook(() => useLogging());\n const [loggingValue] = result.current;\n\n expect(loggingValue).toBe(INITIAL_VALUE);\n });\n\n it('should react to changes to the logging debug setting', () => {\n const INITIAL_VALUE = true;\n const CHANGED_BOOLEAN_VALUE = false;\n\n let updateCallback: Parameters<typeof observeStateChange>[0];\n mocked(isLoggingEnabled).mockReturnValueOnce(INITIAL_VALUE);\n mocked(observeStateChange).mockImplementation((expectedCallback) => {\n updateCallback = expectedCallback;\n return {\n unsubscribe() {},\n };\n });\n\n const { result } = renderHook(() => useLogging());\n let [loggingValue] = result.current;\n\n expect(loggingValue).toBe(INITIAL_VALUE);\n\n act(() => {\n updateCallback({\n discovery: CHANGED_BOOLEAN_VALUE,\n debug: CHANGED_BOOLEAN_VALUE,\n logging: CHANGED_BOOLEAN_VALUE,\n validation: CHANGED_BOOLEAN_VALUE,\n logLevel: LogLevel.warn,\n });\n });\n\n [loggingValue] = result.current;\n\n expect(loggingValue).toBe(CHANGED_BOOLEAN_VALUE);\n });\n});\n"]}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const utils_1 = require("ts-jest/utils");
5
- const react_hooks_1 = require("@testing-library/react-hooks");
6
- const clientside_extensions_debug_1 = require("@atlassian/clientside-extensions-debug");
7
- const useValidation_1 = tslib_1.__importDefault(require("./useValidation"));
8
- jest.mock('@atlassian/clientside-extensions-debug');
9
- describe('useValidation hook', () => {
10
- beforeEach(() => {
11
- utils_1.mocked(clientside_extensions_debug_1.isValidationEnabled).mockClear();
12
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockClear();
13
- });
14
- it('should return the current state of the validation debug setting', () => {
15
- const INITIAL_VALUE = false;
16
- utils_1.mocked(clientside_extensions_debug_1.isValidationEnabled).mockReturnValueOnce(INITIAL_VALUE);
17
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockReturnValueOnce({ unsubscribe() { } });
18
- const { result } = react_hooks_1.renderHook(() => useValidation_1.default());
19
- const [validationValue] = result.current;
20
- expect(validationValue).toBe(INITIAL_VALUE);
21
- });
22
- it('should react to changes to the validation debug setting', () => {
23
- const INITIAL_VALUE = true;
24
- const CHANGED_BOOLEAN_VALUE = false;
25
- let updateCallback;
26
- utils_1.mocked(clientside_extensions_debug_1.isValidationEnabled).mockReturnValueOnce(INITIAL_VALUE);
27
- utils_1.mocked(clientside_extensions_debug_1.observeStateChange).mockImplementation((expectedCallback) => {
28
- updateCallback = expectedCallback;
29
- return {
30
- unsubscribe() { },
31
- };
32
- });
33
- const { result } = react_hooks_1.renderHook(() => useValidation_1.default());
34
- let [validationValue] = result.current;
35
- expect(validationValue).toBe(INITIAL_VALUE);
36
- react_hooks_1.act(() => {
37
- updateCallback({
38
- discovery: CHANGED_BOOLEAN_VALUE,
39
- debug: CHANGED_BOOLEAN_VALUE,
40
- logging: CHANGED_BOOLEAN_VALUE,
41
- validation: CHANGED_BOOLEAN_VALUE,
42
- logLevel: clientside_extensions_debug_1.LogLevel.debug,
43
- });
44
- });
45
- [validationValue] = result.current;
46
- expect(validationValue).toBe(CHANGED_BOOLEAN_VALUE);
47
- });
48
- });
49
- //# sourceMappingURL=useValidation.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useValidation.test.js","sourceRoot":"","sources":["../../../lib/debug/useValidation.test.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AACvC,8DAA+D;AAC/D,wFAA2G;AAC3G,4EAA4C;AAE5C,IAAI,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;AAEpD,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAChC,UAAU,CAAC,GAAG,EAAE;QACZ,cAAM,CAAC,iDAAmB,CAAC,CAAC,SAAS,EAAE,CAAC;QACxC,cAAM,CAAC,gDAAkB,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACvE,MAAM,aAAa,GAAG,KAAK,CAAC;QAC5B,cAAM,CAAC,iD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CAAC;QACP,CAAC,CAAC,CAAC;QAEH,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;QAEnC,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { mocked } from 'ts-jest/utils';\nimport { act, renderHook } from '@testing-library/react-hooks';\nimport { isValidationEnabled, LogLevel, observeStateChange } from '@atlassian/clientside-extensions-debug';\nimport useValidation from './useValidation';\n\njest.mock('@atlassian/clientside-extensions-debug');\n\ndescribe('useValidation hook', () => {\n beforeEach(() => {\n mocked(isValidationEnabled).mockClear();\n mocked(observeStateChange).mockClear();\n });\n\n it('should return the current state of the validation debug setting', () => {\n const INITIAL_VALUE = false;\n mocked(isValidationEnabled).mockReturnValueOnce(INITIAL_VALUE);\n mocked(observeStateChange).mockReturnValueOnce({ unsubscribe() {} });\n\n const { result } = renderHook(() => useValidation());\n const [validationValue] = result.current;\n\n expect(validationValue).toBe(INITIAL_VALUE);\n });\n\n it('should react to changes to the validation debug setting', () => {\n const INITIAL_VALUE = true;\n const CHANGED_BOOLEAN_VALUE = false;\n\n let updateCallback: Parameters<typeof observeStateChange>[0];\n mocked(isValidationEnabled).mockReturnValueOnce(INITIAL_VALUE);\n mocked(observeStateChange).mockImplementation((expectedCallback) => {\n updateCallback = expectedCallback;\n return {\n unsubscribe() {},\n };\n });\n\n const { result } = renderHook(() => useValidation());\n let [validationValue] = result.current;\n\n expect(validationValue).toBe(INITIAL_VALUE);\n\n act(() => {\n updateCallback({\n discovery: CHANGED_BOOLEAN_VALUE,\n debug: CHANGED_BOOLEAN_VALUE,\n logging: CHANGED_BOOLEAN_VALUE,\n validation: CHANGED_BOOLEAN_VALUE,\n logLevel: LogLevel.debug,\n });\n });\n\n [validationValue] = result.current;\n\n expect(validationValue).toBe(CHANGED_BOOLEAN_VALUE);\n });\n});\n"]}
@@ -1,189 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /* eslint-disable react/jsx-props-no-spreading */
5
- const React = tslib_1.__importStar(require("react"));
6
- const react_1 = require("@testing-library/react");
7
- const debug = tslib_1.__importStar(require("@atlassian/clientside-extensions-debug"));
8
- const AsyncPanelHandler_1 = require("./AsyncPanelHandler");
9
- debug.setLoggingEnabled(true);
10
- debug.setDebugEnabled(true);
11
- // avoid spamming the console with error/warn messages
12
- // eslint-disable-next-line no-underscore-dangle
13
- debug._deregisterDefaultLogger();
14
- const onMountCallbackSpy = jest.fn();
15
- const onUnmountCallbackSpy = jest.fn();
16
- const moduleSpy = jest.fn();
17
- // onAction method of an Extension
18
- const createFakeRenderProvider = () => () =>
19
- // fake async module
20
- Promise.resolve({
21
- __esModule: true,
22
- default: moduleSpy,
23
- });
24
- const LOCATION = 'test-location';
25
- const EXTENSION_KEY = 'test-extension';
26
- const TestComponent = (props) => {
27
- return React.createElement(AsyncPanelHandler_1.AsyncPanelHandler, Object.assign({}, props));
28
- };
29
- TestComponent.defaultProps = {
30
- renderProvider: createFakeRenderProvider(),
31
- fallback: React.createElement("p", { "data-testid": "loading" }, "loading"),
32
- location: LOCATION,
33
- extensionKey: EXTENSION_KEY,
34
- };
35
- const getFirstCallArguments = (onDebugSpy) => onDebugSpy.mock.calls[0][0];
36
- describe('AsyncPanelHandler', () => {
37
- const onDebugSpy = jest.fn();
38
- debug.observeLogger(onDebugSpy);
39
- beforeEach(() => {
40
- onMountCallbackSpy.mockReset();
41
- onUnmountCallbackSpy.mockReset();
42
- moduleSpy.mockReset();
43
- onDebugSpy.mockClear();
44
- moduleSpy.mockImplementation((panelAPI /* context, */ /* data */) => {
45
- panelAPI.onMount(onMountCallbackSpy);
46
- panelAPI.onUnmount(onUnmountCallbackSpy);
47
- });
48
- });
49
- it('should load and render the panel content asynchronously', async () => {
50
- const CUSTOM_CONTENT = `custom content`;
51
- onMountCallbackSpy.mockImplementationOnce((container) => {
52
- container.innerHTML = CUSTOM_CONTENT;
53
- });
54
- const { getByText, findByText, queryByTestId } = react_1.render(React.createElement(TestComponent, null));
55
- expect(queryByTestId('loading')).toBeTruthy();
56
- expect(onMountCallbackSpy).toHaveBeenCalledTimes(0);
57
- // wait for element to be on the screen
58
- await findByText(CUSTOM_CONTENT);
59
- expect(getByText(CUSTOM_CONTENT)).toBeTruthy();
60
- expect(queryByTestId('loading')).toBeFalsy();
61
- expect(onMountCallbackSpy).toHaveBeenCalledTimes(1);
62
- });
63
- it('should provide an onMount and onUnmount API', async () => {
64
- const CUSTOM_CONTENT_1 = `custom content 1`;
65
- const CUSTOM_CONTENT_2 = `custom content 2`;
66
- const firstRenderProvider = createFakeRenderProvider();
67
- const secondRenderProvider = createFakeRenderProvider();
68
- onMountCallbackSpy
69
- .mockImplementationOnce((container) => {
70
- container.innerHTML = CUSTOM_CONTENT_1;
71
- })
72
- .mockImplementationOnce((container) => {
73
- container.innerHTML = CUSTOM_CONTENT_2;
74
- });
75
- const { rerender, findByText, queryByTestId, queryByText } = react_1.render(React.createElement(TestComponent, { renderProvider: firstRenderProvider }));
76
- expect(queryByTestId('loading')).toBeTruthy();
77
- expect(onMountCallbackSpy).toHaveBeenCalledTimes(0);
78
- expect(onUnmountCallbackSpy).toHaveBeenCalledTimes(0);
79
- // wait for element to be on the screen
80
- await findByText(CUSTOM_CONTENT_1);
81
- expect(queryByText(CUSTOM_CONTENT_1)).toBeTruthy();
82
- expect(queryByTestId('loading')).toBeFalsy();
83
- expect(onMountCallbackSpy).toHaveBeenCalledTimes(1);
84
- expect(onUnmountCallbackSpy).toHaveBeenCalledTimes(0);
85
- rerender(React.createElement(TestComponent, { renderProvider: secondRenderProvider }));
86
- // wait for element to be on the screen
87
- await findByText(CUSTOM_CONTENT_2);
88
- expect(queryByText(CUSTOM_CONTENT_2)).toBeTruthy();
89
- expect(queryByText(CUSTOM_CONTENT_1)).toBeFalsy();
90
- expect(queryByTestId('loading')).toBeFalsy();
91
- expect(onMountCallbackSpy).toHaveBeenCalledTimes(2);
92
- expect(onUnmountCallbackSpy).toHaveBeenCalledTimes(1);
93
- });
94
- it('should catch the error if the async module has a wrong shape', async () => {
95
- const expectedError = {
96
- level: debug.LogLevel.error,
97
- message: `The provided dynamic import of extension "${EXTENSION_KEY}" at location "${LOCATION}" does not look like a module that can be asynchronously loaded.`,
98
- components: ['AsyncPanelHandler'],
99
- meta: {
100
- location: LOCATION,
101
- extension: EXTENSION_KEY,
102
- },
103
- };
104
- expect(onDebugSpy).toHaveBeenCalledTimes(0);
105
- // @ts-expect-error - ignoring to force assigment of an empty object as a resolved module
106
- const { getByText } = react_1.render(React.createElement(TestComponent, { renderProvider: () => Promise.resolve({}) }));
107
- await react_1.waitForElementToBeRemoved(() => getByText('loading'));
108
- expect(onDebugSpy).toHaveBeenCalledTimes(1);
109
- expect(getFirstCallArguments(onDebugSpy)).toMatchObject(expectedError);
110
- });
111
- it('should catch any error thrown by the render provider', async () => {
112
- const expectedError = {
113
- level: debug.LogLevel.error,
114
- message: `Failed trying to execute the dynamic import from extension "${EXTENSION_KEY}" for the async panel at location "${LOCATION}"`,
115
- components: ['AsyncPanelHandler'],
116
- meta: {
117
- location: LOCATION,
118
- extension: EXTENSION_KEY,
119
- error: new Error('test render error'),
120
- },
121
- };
122
- expect(onDebugSpy).toHaveBeenCalledTimes(0);
123
- const { getByText } = react_1.render(React.createElement(TestComponent, { renderProvider: () => {
124
- throw new Error('test render error');
125
- } }));
126
- await react_1.waitForElementToBeRemoved(() => getByText('loading'));
127
- expect(onDebugSpy).toHaveBeenCalledTimes(1);
128
- expect(getFirstCallArguments(onDebugSpy)).toMatchObject(expectedError);
129
- });
130
- it('should pass the context to the async module when the module was loaded', async () => {
131
- // given
132
- const contextValue = {
133
- myCounter: 1234,
134
- };
135
- const contextProvider = () => contextValue;
136
- onMountCallbackSpy.mockImplementation((container) => {
137
- const contextArgPos = 1;
138
- const lastContext = moduleSpy.mock.calls[moduleSpy.mock.calls.length - 1][contextArgPos];
139
- container.innerHTML = `<p data-testid="label">My counter is: <strong data-testid="counter">${lastContext.myCounter}</strong></p>`;
140
- });
141
- // when
142
- const { findByTestId, getByTestId } = react_1.render(React.createElement(TestComponent, { contextProvider: contextProvider }));
143
- await findByTestId('counter');
144
- // then
145
- expect(getByTestId('label').textContent).toEqual('My counter is: 1234');
146
- expect(moduleSpy).toHaveBeenLastCalledWith(expect.any(Object), contextValue);
147
- expect(onDebugSpy).toHaveBeenCalledTimes(0);
148
- });
149
- it('should propagate the latest value of the context to the async module', async () => {
150
- // given
151
- const contextValue = {
152
- myCounter: 1234,
153
- };
154
- const contextProvider = () => contextValue;
155
- // when
156
- const { getByText, rerender } = react_1.render(React.createElement(TestComponent, { contextProvider: contextProvider }));
157
- await react_1.waitForElementToBeRemoved(() => getByText('loading'));
158
- // then
159
- expect(moduleSpy).toHaveBeenLastCalledWith(expect.any(Object), contextValue);
160
- expect(onDebugSpy).toHaveBeenCalledTimes(0);
161
- // New context value
162
- const newContextValue = 9876;
163
- const newContextProvider = () => newContextValue;
164
- rerender(React.createElement(TestComponent, { contextProvider: newContextProvider }));
165
- expect(moduleSpy).toHaveBeenLastCalledWith(expect.any(Object), newContextValue);
166
- expect(onDebugSpy).toHaveBeenCalledTimes(0);
167
- });
168
- it('should log an error when failed invoking context provider', async () => {
169
- // given
170
- const contextProvider = () => {
171
- throw new SyntaxError();
172
- };
173
- // when
174
- const { getByText } = react_1.render(React.createElement(TestComponent, { contextProvider: contextProvider }));
175
- await react_1.waitForElementToBeRemoved(() => getByText('loading'));
176
- // then
177
- expect(onDebugSpy).toHaveBeenCalledTimes(1);
178
- expect(getFirstCallArguments(onDebugSpy)).toMatchObject({
179
- level: debug.LogLevel.error,
180
- message: `Failed to invoke "contextProvider" function for extension "${EXTENSION_KEY}" at location "${LOCATION}".\nError: SyntaxError`,
181
- components: ['AsyncPanelHandler'],
182
- meta: {
183
- location: LOCATION,
184
- extension: EXTENSION_KEY,
185
- },
186
- });
187
- });
188
- });
189
- //# sourceMappingURL=AsyncPanelHandler.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AsyncPanelHandler.test.js","sourceRoot":"","sources":["../../../lib/handlers/AsyncPanelHandler.test.tsx"],"names":[],"mappings":";;;AAAA,iDAAiD;AACjD,qDAA+B;AAC/B,kDAA2E;AAC3E,sFAAgE;AAEhE,2DAAwD;AAGxD,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAC9B,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC5B,sDAAsD;AACtD,gDAAgD;AAChD,KAAK,CAAC,wBAAwB,EAAE,CAAC;AAEjC,MAAM,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACrC,MAAM,oBAAoB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACvC,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAE5B,kCAAkC;AAClC,MAAM,wBAAwB,GAAoC,GAA8B,EAAE,CAAC,GAAG,EAAE;AACpG,oBAAoB;AACpB,OAAO,CAAC,OAAO,CAAC;IACZ,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,SAAS;CACrB,CAAC,CAAC;AAEP,MAAM,QAAQ,GAAG,eAAe,CAAC;AACjC,MAAM,aAAa,GAAG,gBAAgB,CAAC;AACvC,MAAM,aAAa,GAAG,CAAC,KAA6B,EAAE,EAAE;IACpD,OAAO,oBAAC,qCAAiB,oBAAK,KAAK,EAAI,CAAC;AAC5C,CAAC,CAAC;AACF,aAAa,CAAC,YAAY,GAAG;IACzB,cAAc,EAAE,wBAAwB,EAAE;IAC1C,QAAQ,EAAE,0CAAe,SAAS,cAAY;IAC9C,QAAQ,EAAE,QAAQ;IAClB,YAAY,EAAE,aAAa;CACK,CAAC;AAErC,MAAM,qBAAqB,GAAG,CAAC,UAAqB,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,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;gBAClB,SAAS,EAAE,aAAa;aAC3B;SACJ,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\nimport * as React from 'react';\nimport { render, waitForElementToBeRemoved } from '@testing-library/react';\nimport * as debug from '@atlassian/clientside-extensions-debug';\n\nimport { AsyncPanelHandler } from './AsyncPanelHandler';\nimport type { AsyncPanelRenderExtension, AsyncPanelHandlerProps } from './AsyncPanelHandler';\n\ndebug.setLoggingEnabled(true);\ndebug.setDebugEnabled(true);\n// avoid spamming the console with error/warn messages\n// eslint-disable-next-line no-underscore-dangle\ndebug._deregisterDefaultLogger();\n\nconst onMountCallbackSpy = jest.fn();\nconst onUnmountCallbackSpy = jest.fn();\nconst moduleSpy = jest.fn();\n\n// onAction method of an Extension\nconst createFakeRenderProvider: () => AsyncPanelRenderExtension = (): AsyncPanelRenderExtension => () =>\n // fake async module\n Promise.resolve({\n __esModule: true,\n default: moduleSpy,\n });\n\nconst LOCATION = 'test-location';\nconst EXTENSION_KEY = 'test-extension';\nconst TestComponent = (props: AsyncPanelHandlerProps) => {\n return <AsyncPanelHandler {...props} />;\n};\nTestComponent.defaultProps = {\n renderProvider: createFakeRenderProvider(),\n fallback: <p data-testid=\"loading\">loading</p>,\n location: LOCATION,\n extensionKey: EXTENSION_KEY,\n} as Partial<AsyncPanelHandlerProps>;\n\nconst getFirstCallArguments = (onDebugSpy: jest.Mock) => onDebugSpy.mock.calls[0][0];\n\ndescribe('AsyncPanelHandler', () => {\n const onDebugSpy = jest.fn();\n debug.observeLogger(onDebugSpy);\n\n beforeEach(() => {\n onMountCallbackSpy.mockReset();\n onUnmountCallbackSpy.mockReset();\n moduleSpy.mockReset();\n onDebugSpy.mockClear();\n\n moduleSpy.mockImplementation((panelAPI /* context, */ /* data */) => {\n panelAPI.onMount(onMountCallbackSpy);\n panelAPI.onUnmount(onUnmountCallbackSpy);\n });\n });\n\n it('should load and render the panel content asynchronously', async () => {\n const CUSTOM_CONTENT = `custom content`;\n onMountCallbackSpy.mockImplementationOnce((container: HTMLElement) => {\n container.innerHTML = CUSTOM_CONTENT;\n });\n\n const { getByText, findByText, queryByTestId } = render(<TestComponent />);\n\n expect(queryByTestId('loading')).toBeTruthy();\n expect(onMountCallbackSpy).toHaveBeenCalledTimes(0);\n\n // wait for element to be on the screen\n await findByText(CUSTOM_CONTENT);\n\n expect(getByText(CUSTOM_CONTENT)).toBeTruthy();\n expect(queryByTestId('loading')).toBeFalsy();\n expect(onMountCallbackSpy).toHaveBeenCalledTimes(1);\n });\n\n it('should provide an onMount and onUnmount API', async () => {\n const CUSTOM_CONTENT_1 = `custom content 1`;\n const CUSTOM_CONTENT_2 = `custom content 2`;\n\n const firstRenderProvider = createFakeRenderProvider();\n const secondRenderProvider = createFakeRenderProvider();\n\n onMountCallbackSpy\n .mockImplementationOnce((container: HTMLElement) => {\n container.innerHTML = CUSTOM_CONTENT_1;\n })\n .mockImplementationOnce((container: HTMLElement) => {\n container.innerHTML = CUSTOM_CONTENT_2;\n });\n\n const { rerender, findByText, queryByTestId, queryByText } = render(<TestComponent renderProvider={firstRenderProvider} />);\n\n expect(queryByTestId('loading')).toBeTruthy();\n expect(onMountCallbackSpy).toHaveBeenCalledTimes(0);\n expect(onUnmountCallbackSpy).toHaveBeenCalledTimes(0);\n\n // wait for element to be on the screen\n await findByText(CUSTOM_CONTENT_1);\n\n expect(queryByText(CUSTOM_CONTENT_1)).toBeTruthy();\n expect(queryByTestId('loading')).toBeFalsy();\n expect(onMountCallbackSpy).toHaveBeenCalledTimes(1);\n expect(onUnmountCallbackSpy).toHaveBeenCalledTimes(0);\n\n rerender(<TestComponent renderProvider={secondRenderProvider} />);\n\n // wait for element to be on the screen\n await findByText(CUSTOM_CONTENT_2);\n\n expect(queryByText(CUSTOM_CONTENT_2)).toBeTruthy();\n expect(queryByText(CUSTOM_CONTENT_1)).toBeFalsy();\n expect(queryByTestId('loading')).toBeFalsy();\n expect(onMountCallbackSpy).toHaveBeenCalledTimes(2);\n expect(onUnmountCallbackSpy).toHaveBeenCalledTimes(1);\n });\n\n it('should catch the error if the async module has a wrong shape', async () => {\n const expectedError = {\n level: debug.LogLevel.error,\n\n message: `The provided dynamic import of extension \"${EXTENSION_KEY}\" at location \"${LOCATION}\" does not look like a module that can be asynchronously loaded.`,\n components: ['AsyncPanelHandler'],\n meta: {\n location: LOCATION,\n extension: EXTENSION_KEY,\n },\n };\n\n expect(onDebugSpy).toHaveBeenCalledTimes(0);\n\n // @ts-expect-error - ignoring to force assigment of an empty object as a resolved module\n const { getByText } = render(<TestComponent renderProvider={() => Promise.resolve({})} />);\n\n await waitForElementToBeRemoved(() => getByText('loading'));\n\n expect(onDebugSpy).toHaveBeenCalledTimes(1);\n expect(getFirstCallArguments(onDebugSpy)).toMatchObject(expectedError);\n });\n\n it('should catch any error thrown by the render provider', async () => {\n const expectedError = {\n level: debug.LogLevel.error,\n\n message: `Failed trying to execute the dynamic import from extension \"${EXTENSION_KEY}\" for the async panel at location \"${LOCATION}\"`,\n components: ['AsyncPanelHandler'],\n meta: {\n location: LOCATION,\n extension: EXTENSION_KEY,\n error: new Error('test render error'),\n },\n };\n\n expect(onDebugSpy).toHaveBeenCalledTimes(0);\n\n const { getByText } = render(\n <TestComponent\n renderProvider={() => {\n throw new Error('test render error');\n }}\n />,\n );\n\n await waitForElementToBeRemoved(() => getByText('loading'));\n\n expect(onDebugSpy).toHaveBeenCalledTimes(1);\n expect(getFirstCallArguments(onDebugSpy)).toMatchObject(expectedError);\n });\n\n it('should pass the context to the async module when the module was loaded', async () => {\n // given\n const contextValue = {\n myCounter: 1234,\n };\n\n const contextProvider = () => contextValue;\n\n onMountCallbackSpy.mockImplementation((container: HTMLElement) => {\n const contextArgPos = 1;\n const lastContext = moduleSpy.mock.calls[moduleSpy.mock.calls.length - 1][contextArgPos];\n\n container.innerHTML = `<p data-testid=\"label\">My counter is: <strong data-testid=\"counter\">${lastContext.myCounter}</strong></p>`;\n });\n\n // when\n const { findByTestId, getByTestId } = render(<TestComponent contextProvider={contextProvider} />);\n\n await findByTestId('counter');\n\n // then\n expect(getByTestId('label').textContent).toEqual('My counter is: 1234');\n expect(moduleSpy).toHaveBeenLastCalledWith(expect.any(Object), contextValue);\n expect(onDebugSpy).toHaveBeenCalledTimes(0);\n });\n\n it('should propagate the latest value of the context to the async module', async () => {\n // given\n const contextValue = {\n myCounter: 1234,\n };\n\n const contextProvider = () => contextValue;\n\n // when\n const { getByText, rerender } = render(<TestComponent contextProvider={contextProvider} />);\n\n await waitForElementToBeRemoved(() => getByText('loading'));\n\n // then\n expect(moduleSpy).toHaveBeenLastCalledWith(expect.any(Object), contextValue);\n expect(onDebugSpy).toHaveBeenCalledTimes(0);\n\n // New context value\n const newContextValue = 9876;\n const newContextProvider = () => newContextValue;\n\n rerender(<TestComponent contextProvider={newContextProvider} />);\n\n expect(moduleSpy).toHaveBeenLastCalledWith(expect.any(Object), newContextValue);\n expect(onDebugSpy).toHaveBeenCalledTimes(0);\n });\n\n it('should log an error when failed invoking context provider', async () => {\n // given\n const contextProvider = () => {\n throw new SyntaxError();\n };\n\n // when\n const { getByText } = render(<TestComponent contextProvider={contextProvider} />);\n\n await waitForElementToBeRemoved(() => getByText('loading'));\n\n // then\n expect(onDebugSpy).toHaveBeenCalledTimes(1);\n expect(getFirstCallArguments(onDebugSpy)).toMatchObject({\n level: debug.LogLevel.error,\n\n message: `Failed to invoke \"contextProvider\" function for extension \"${EXTENSION_KEY}\" at location \"${LOCATION}\".\\nError: SyntaxError`,\n components: ['AsyncPanelHandler'],\n meta: {\n location: LOCATION,\n extension: EXTENSION_KEY,\n },\n });\n });\n});\n"]}
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const React = tslib_1.__importStar(require("react"));
5
- const react_1 = require("@testing-library/react");
6
- require("@testing-library/jest-dom");
7
- const ButtonHandler_1 = require("./ButtonHandler");
8
- const TestComponent = ({ onAction, attributes, children }) => {
9
- return (
10
- // eslint-disable-next-line react/jsx-props-no-spreading
11
- React.createElement(ButtonHandler_1.ButtonHandler, Object.assign({ onAction: onAction }, attributes), children));
12
- };
13
- describe('ButtonHandler', () => {
14
- const buttonText = 'CLICK ME';
15
- let actionHandler;
16
- beforeEach(() => {
17
- actionHandler = jest.fn();
18
- });
19
- it('should render a button', async () => {
20
- var _a;
21
- const { queryByText } = react_1.render(React.createElement(TestComponent, { onAction: actionHandler }, buttonText));
22
- expect(await ((_a = queryByText(buttonText)) === null || _a === void 0 ? void 0 : _a.closest('button'))).toBeTruthy();
23
- });
24
- it('should render a disabled button', async () => {
25
- var _a;
26
- const { queryByText } = react_1.render(React.createElement(TestComponent, { onAction: actionHandler, attributes: { disabled: true } }, buttonText));
27
- expect((_a = (await queryByText(buttonText))) === null || _a === void 0 ? void 0 : _a.closest('button')).toBeDisabled();
28
- });
29
- it('should render nothing if "hidden" is true', async () => {
30
- const { queryByText } = react_1.render(React.createElement(TestComponent, { onAction: actionHandler, attributes: { hidden: true } }, buttonText));
31
- expect(await queryByText(buttonText)).toBeNull();
32
- });
33
- it('should correctly set the action handler', async () => {
34
- var _a;
35
- const { queryByText } = react_1.render(React.createElement(TestComponent, { onAction: actionHandler }, buttonText));
36
- await ((_a = queryByText(buttonText)) === null || _a === void 0 ? void 0 : _a.click());
37
- expect(actionHandler).toBeCalledTimes(1);
38
- });
39
- });
40
- //# sourceMappingURL=ButtonHandler.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ButtonHandler.test.js","sourceRoot":"","sources":["../../../lib/handlers/ButtonHandler.test.tsx"],"names":[],"mappings":";;;AAAA,qDAA+B;AAC/B,kDAAgD;AAChD,qCAAmC;AAGnC,mDAAgD;AAGhD,MAAM,aAAa,GAAqE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3H,OAAO;IACH,wDAAwD;IACxD,oBAAC,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AAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;;QACrD,MAAM,EAAE,WAAW,EAAE,GAAG,cAAM,CAAC,oBAAC,aAAa,IAAC,QAAQ,EAAE,aAAa,IAAG,UAAU,CAAiB,CAAC,CAAC;QAErG,aAAM,WAAW,CAAC,UAAU,CAAC,0CAAE,KAAK,GAAE,CAAC;QAEvC,MAAM,CAAC,aAAa,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { render } from '@testing-library/react';\nimport '@testing-library/jest-dom';\n\nimport type { FunctionComponent } from 'react';\nimport { ButtonHandler } from './ButtonHandler';\nimport Mock = jest.Mock;\n\nconst TestComponent: FunctionComponent<{ onAction: () => void; attributes?: object }> = ({ onAction, attributes, children }) => {\n return (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <ButtonHandler onAction={onAction} {...attributes}>\n {children}\n </ButtonHandler>\n );\n};\n\ndescribe('ButtonHandler', () => {\n const buttonText = 'CLICK ME';\n let actionHandler: Mock;\n\n beforeEach(() => {\n actionHandler = jest.fn();\n });\n\n it('should render a button', async () => {\n const { queryByText } = render(<TestComponent onAction={actionHandler}>{buttonText}</TestComponent>);\n\n expect(await queryByText(buttonText)?.closest('button')).toBeTruthy();\n });\n\n it('should render a disabled button', async () => {\n const { queryByText } = render(\n <TestComponent onAction={actionHandler} attributes={{ disabled: true }}>\n {buttonText}\n </TestComponent>,\n );\n\n expect((await queryByText(buttonText))?.closest('button')).toBeDisabled();\n });\n\n it('should render nothing if \"hidden\" is true', async () => {\n const { queryByText } = render(\n <TestComponent onAction={actionHandler} attributes={{ hidden: true }}>\n {buttonText}\n </TestComponent>,\n );\n\n expect(await queryByText(buttonText)).toBeNull();\n });\n\n it('should correctly set the action handler', async () => {\n const { queryByText } = render(<TestComponent onAction={actionHandler}>{buttonText}</TestComponent>);\n\n await queryByText(buttonText)?.click();\n\n expect(actionHandler).toBeCalledTimes(1);\n });\n});\n"]}