Title: Add specs to auto-scroll.hook · Issue #142 · Lemoncode/code-paster · GitHub
Open Graph Title: Add specs to auto-scroll.hook · Issue #142 · Lemoncode/code-paster
X Title: Add specs to auto-scroll.hook · Issue #142 · Lemoncode/code-paster
Description: Here you have a working tests checking the scrollTop value when it calls doAutoScroll. import { textarea } from 'pods/trainer/components/new-text.styles'; import React from 'react'; import { renderHook } from '@testing-library/react-hook...
Open Graph Description: Here you have a working tests checking the scrollTop value when it calls doAutoScroll. import { textarea } from 'pods/trainer/components/new-text.styles'; import React from 'react'; import { render...
X Description: Here you have a working tests checking the scrollTop value when it calls doAutoScroll. import { textarea } from 'pods/trainer/components/new-text.styles'; import React from 'react';...
Opengraph URL: https://github.com/Lemoncode/code-paster/issues/142
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add specs to auto-scroll.hook","articleBody":"Here you have a working tests checking the scrollTop value when it calls `doAutoScroll`.\r\n\r\n```\r\nimport { textarea } from 'pods/trainer/components/new-text.styles';\r\nimport React from 'react';\r\nimport { renderHook } from '@testing-library/react-hooks';\r\nimport { useAutoScroll } from './auto-scroll.hook';\r\n\r\ndescribe('src/common/hooks/auto-scroll.hook specs', () =\u003e {\r\n it('should return initial values when it renders the hook', () =\u003e {\r\n // Arrange\r\n const textArea = {\r\n scrollHeight: 10,\r\n scrollTop: undefined,\r\n };\r\n\r\n jest.spyOn(React, 'useRef').mockReturnValue({\r\n current: textArea,\r\n });\r\n\r\n // Act\r\n const { result } = renderHook(() =\u003e useAutoScroll());\r\n\r\n // Assert\r\n expect(result.current.isAutoScrollEnabled).toBeTruthy();\r\n expect(result.current.textAreaRef.current).not.toBeNull();\r\n expect(result.current.textAreaRef.current.scrollHeight).toEqual(10);\r\n expect(result.current.textAreaRef.current.scrollTop).toBeUndefined();\r\n });\r\n\r\n it('should update scrollTop with height value when it call doAutoScroll', () =\u003e {\r\n // Arrange\r\n const textArea = {\r\n scrollHeight: 10,\r\n scrollTop: undefined,\r\n };\r\n\r\n jest.spyOn(React, 'useRef').mockReturnValue({\r\n current: textArea,\r\n });\r\n\r\n // Act\r\n const { result } = renderHook(() =\u003e useAutoScroll());\r\n\r\n result.current.doAutoScroll();\r\n\r\n // Assert\r\n expect(result.current.textAreaRef.current.scrollTop).toEqual(10);\r\n });\r\n});\r\n\r\n```\r\n\r\n- Pending specs:\r\n - Disable auto scroll and check `isAutoScrollEnabled` value\r\n - Disable auto scroll, calls `doAutoScroll` and check it doesn't update the `scrollTop` value.","author":{"url":"https://github.com/nasdan","@type":"Person","name":"nasdan"},"datePublished":"2021-02-20T09:28:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/142/code-paster/issues/142"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:713cc771-00eb-9dbf-978a-27a8f1bde69e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C83E:8884A:70A9A:9E85E:69789C6C |
| html-safe-nonce | 7340da3c13b4e6922bfb8efa6c6f53d9598d63d58c5797c3f388789a4194779d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODNFOjg4ODRBOjcwQTlBOjlFODVFOjY5Nzg5QzZDIiwidmlzaXRvcl9pZCI6IjQwMTAwMzY3NDQ5OTEzMTcxMDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 34a6d3b78576650793c27dccf8d6feec2df62115ae6e826450233982befcab05 |
| hovercard-subject-tag | issue:812563196 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Lemoncode/code-paster/142/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f9faead3a67933b5405d072847ccad3a19435b8c6ac30b5ed7e8447895d6925f/Lemoncode/code-paster/issues/142 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f9faead3a67933b5405d072847ccad3a19435b8c6ac30b5ed7e8447895d6925f/Lemoncode/code-paster/issues/142 |
| og:image:alt | Here you have a working tests checking the scrollTop value when it calls doAutoScroll. import { textarea } from 'pods/trainer/components/new-text.styles'; import React from 'react'; import { render... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nasdan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2981c597c945c1d90ac6fa355ce7929b2f413dfe7872ca5c435ee53a24a1de50 |
| turbo-cache-control | no-preview |
| go-import | github.com/Lemoncode/code-paster git https://github.com/Lemoncode/code-paster.git |
| octolytics-dimension-user_id | 7702396 |
| octolytics-dimension-user_login | Lemoncode |
| octolytics-dimension-repository_id | 295726411 |
| octolytics-dimension-repository_nwo | Lemoncode/code-paster |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 295726411 |
| octolytics-dimension-repository_network_root_nwo | Lemoncode/code-paster |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 14920c7cb7d7c207b5e72684d0e6f23b65b849b3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width