Repository: ant-design/ant-design-mobile
Pull request #5683 (2022-09-23 02:38:32)

test(footer): add some tests

github-actions[bot]: PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5683.surge.sh
codecov[bot]: # [Codecov](https://codecov.io/gh/ant-design/ant-design-mobile/pull/5683?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) Report
Base: **89.44**% // Head: **90.01**% // Increases project coverage by **`+0.56%`** :tada:
> Coverage data is based on head [(`abbbb7a`)](https://codecov.io/gh/ant-design/ant-design-mobile/pull/5683?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) compared to base [(`0316cf8`)](https://codecov.io/gh/ant-design/ant-design-mobile/commit/0316cf8554ad8890dd0d6093fa2eca9446d8aac3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design).
> Patch has no changes to coverable lines.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #5683      +/-   ##
==========================================
+ Coverage   89.44%   90.01%   +0.56%     
==========================================
  Files         296      296              
  Lines        6327     6327              
  Branches     1551     1551              
==========================================
+ Hits         5659     5695      +36     
+ Misses        618      584      -34     
+ Partials       50       48       -2     
```


| [Impacted Files](https://codecov.io/gh/ant-design/ant-design-mobile/pull/5683?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) | Coverage Δ | |
|---|---|---|
| [src/components/image-uploader/image-uploader.tsx](https://codecov.io/gh/ant-design/ant-design-mobile/pull/5683/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2NvbXBvbmVudHMvaW1hZ2UtdXBsb2FkZXIvaW1hZ2UtdXBsb2FkZXIudHN4) | `92.72% <0.00%> (+6.36%)` | :arrow_up: |
| [src/components/divider/divider.tsx](https://codecov.io/gh/ant-design/ant-design-mobile/pull/5683/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2NvbXBvbmVudHMvZGl2aWRlci9kaXZpZGVyLnRzeA==) | `100.00% <0.00%> (+36.36%)` | :arrow_up: |
| [src/components/footer/footer.tsx](https://codecov.io/gh/ant-design/ant-design-mobile/pull/5683/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2NvbXBvbmVudHMvZm9vdGVyL2Zvb3Rlci50c3g=) | `100.00% <0.00%> (+75.75%)` | :arrow_up: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/ant-design/ant-design-mobile/pull/5683?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design).


Patch:
diff --git a/src/components/number-keyboard/number-keyboard.less b/src/components/number-keyboard/number-keyboard.less
index 7cb791d94..d23bfb2b1 100644
--- a/src/components/number-keyboard/number-keyboard.less
+++ b/src/components/number-keyboard/number-keyboard.less
@@ -6,7 +6,7 @@
     flex-wrap: wrap;
     flex: 1;
     &&-confirmed-style .@{class-prefix-number-keyboard}-key-sign {
-      background-color: var(--adm-color-white);
+      background-color: var(--adm-color-background);
     }
   }
 


Test patch:
diff --git a/src/components/footer/tests/footer.test.tsx b/src/components/footer/tests/footer.test.tsx
new file mode 100644
index 000000000..433a124e8
--- /dev/null
+++ b/src/components/footer/tests/footer.test.tsx
@@ -0,0 +1,71 @@
+import React from 'react'
+import { render, testA11y, fireEvent, waitFor, screen } from 'testing'
+import Footer from '..'
+
+const classPrefix = `adm-footer`
+
+describe('Footer', () => {
+  test('renders with label', () => {
+    render(<Footer label='no more' />)
+    expect(document.querySelector(`.${classPrefix}-label`)).toHaveTextContent(
+      'no more'
+    )
+  })
+
+  test('renders with custom label', () => {
+    render(<Footer label={<div className='custom-label'></div>} />)
+    expect(document.querySelector('.custom-label')).toBeInTheDocument()
+  })
+
+  test('renders with content', () => {
+    render(<Footer content='@ 2022' />)
+    expect(document.querySelector(`.${classPrefix}-content`)).toHaveTextContent(
+      '@ 2022'
+    )
+  })
+
+  test('renders with links', () => {
+    const onLinkClick = jest.fn()
+    render(
+      <Footer
+        links={[
+          {
+            text: 'antd mobile',
+            href: 'https://mobile.ant.design/',
+          },
+        ]}
+        onLinkClick={onLinkClick}
+      />
+    )
+    expect(document.querySelector(`.${classPrefix}-links`)).toHaveTextContent(
+      'antd mobile'
+    )
+    fireEvent.click(screen.getByText('antd mobile'))
+    expect(onLinkClick).toBeCalled()
+  })
+
+  test('renders with chips', () => {
+    const onChipClick = jest.fn()
+    render(
+      <Footer
+        chips={[
+          {
+            text: 'antd',
+          },
+          {
+            text: 'mobile',
+            type: 'link',
+          },
+        ]}
+        onChipClick={onChipClick}
+      />
+    )
+    expect(document.querySelectorAll(`.${classPrefix}-chip`)).toHaveLength(2)
+    fireEvent.click(screen.getByText('antd'))
+    expect(onChipClick).not.toBeCalled()
+
+    expect(screen.getByText('mobile')).toHaveClass(`${classPrefix}-chip-link`)
+    fireEvent.click(screen.getByText('mobile'))
+    expect(onChipClick).toBeCalled()
+  })
+})