{logo && (
- {logo.icon && }
+ {logo.icon && }
{logo.title && {logo.title}}
)}
diff --git a/src/footer/__tests__/footer.test.tsx b/src/footer/__tests__/footer.test.tsx
new file mode 100644
index 000000000..6d793e1d4
--- /dev/null
+++ b/src/footer/__tests__/footer.test.tsx
@@ -0,0 +1,67 @@
+import { render } from '@test/utils';
+import { describe, test, expect } from 'vitest';
+import React from 'react';
+import Footer from '../Footer';
+
+describe('Footer', () => {
+ describe('props', () => {
+ test(': text', () => {
+ const text = 'Hello. TDesign Footer.';
+ const { container } = render(
);
+ const textElement = container.querySelector('.t-footer__text');
+ expect(textElement).toBeTruthy();
+ expect(textElement.innerHTML).toBe(text);
+ });
+
+ test('logo with title', () => {
+ const logo = {
+ icon: 'https://tdesign.gtimg.com/mobile/demos/logo2.png',
+ title: '品牌名称',
+ };
+ const { container } = render(
);
+ const imgElement = container.querySelector('.t-footer__icon img');
+ expect(imgElement).toBeTruthy();
+ expect(imgElement.getAttribute('src')).toBe(logo.icon);
+ const logoTitleElement = container.querySelector('.t-footer__title');
+ expect(logoTitleElement).toBeTruthy();
+ expect(logoTitleElement.innerHTML).toBe(logo.title);
+ });
+
+ test('logo without title', () => {
+ const logo = {
+ icon: 'https://tdesign.gtimg.com/mobile/demos/logo2.png',
+ };
+ const { container } = render(
);
+ const imgElement = container.querySelector('.t-footer__title-url');
+ expect(imgElement).toBeTruthy();
+ });
+
+ test(': links', () => {
+ const links = [
+ {
+ name: '底部链接A',
+ url: 'https://a',
+ },
+ {
+ name: '底部链接B',
+ url: 'https://b',
+ },
+ ];
+ const { container } = render(
);
+ expect(container.querySelector('.t-footer__link-list')).toBeTruthy();
+ const itemsElement = container.querySelectorAll('.t-footer__link-item');
+ expect(itemsElement.length).toBe(links.length);
+ expect(itemsElement[0].innerHTML).toBe(links[0].name);
+ });
+
+ test(': className', () => {
+ const { container } = render(
);
+ expect(container.querySelector('.t-footer.custom-class')).toBeTruthy();
+ });
+
+ test(': style', () => {
+ const { container } = render(
);
+ expect(window.getComputedStyle(container.querySelector('.t-footer')).fontSize).toBe('100px');
+ });
+ });
+});
diff --git a/src/footer/_example/links.tsx b/src/footer/_example/links.tsx
index 25c40104f..747b9cae6 100644
--- a/src/footer/_example/links.tsx
+++ b/src/footer/_example/links.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import { Footer } from 'tdesign-mobile-react';
-const text = 'Copyright © 2021-2031 TD.All Rights Reserved.';
+const text = 'Copyright © 2019-2023 TDesign.All Rights Reserved.';
const links = [
[
diff --git a/src/footer/_example/logo.tsx b/src/footer/_example/logo.tsx
index 83c96ac00..53dba5acc 100644
--- a/src/footer/_example/logo.tsx
+++ b/src/footer/_example/logo.tsx
@@ -2,10 +2,19 @@ import React from 'react';
import { Footer } from 'tdesign-mobile-react';
const logo = {
- icon: 'https://tdesign.gtimg.com/mobile/demos/logo2.png',
- title: '品牌名称',
+ icon: 'https://tdesign.gtimg.com/mobile/demos/logo1.png',
};
+const text = 'Copyright © 2019-2023 TDesign.All Rights Reserved.';
export default function LogoDemo() {
- return
;
+ return (
+ <>
+
+
+
+
+
+
+ >
+ );
}
diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap
index db2febc61..cc021f42e 100644
--- a/test/snap/__snapshots__/csr.test.jsx.snap
+++ b/test/snap/__snapshots__/csr.test.jsx.snap
@@ -53903,7 +53903,7 @@ exports[`csr snapshot test > csr test src/fab/_example/index.tsx 1`] = `
exports[`csr snapshot test > csr test src/footer/_example/base.tsx 1`] = `