From d96d137893ec3b9f73087738aa3c052cdc5e971b Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 20 Jul 2021 17:09:11 +0800 Subject: [PATCH] test: add some testcase --- package.json | 1 + .../__tests__/AlertErrorView.spec.tsx | 10 ++ .../components/__tests__/Highlight.spec.tsx | 10 ++ web/src/components/__tests__/IconBtn.spec.tsx | 10 ++ .../__tests__/IsDeveloping.spec.tsx | 10 ++ .../components/__tests__/PillTabs.spec.tsx | 19 +++ .../AlertErrorView.spec.tsx.snap | 26 ++++ .../__snapshots__/Highlight.spec.tsx.snap | 11 ++ .../__snapshots__/IconBtn.spec.tsx.snap | 12 ++ .../__snapshots__/IsDeveloping.spec.tsx.snap | 16 +++ .../__snapshots__/PillTabs.spec.tsx.snap | 117 ++++++++++++++++++ yarn.lock | 12 ++ 12 files changed, 254 insertions(+) create mode 100644 web/src/components/__tests__/AlertErrorView.spec.tsx create mode 100644 web/src/components/__tests__/Highlight.spec.tsx create mode 100644 web/src/components/__tests__/IconBtn.spec.tsx create mode 100644 web/src/components/__tests__/IsDeveloping.spec.tsx create mode 100644 web/src/components/__tests__/PillTabs.spec.tsx create mode 100644 web/src/components/__tests__/__snapshots__/AlertErrorView.spec.tsx.snap create mode 100644 web/src/components/__tests__/__snapshots__/Highlight.spec.tsx.snap create mode 100644 web/src/components/__tests__/__snapshots__/IconBtn.spec.tsx.snap create mode 100644 web/src/components/__tests__/__snapshots__/IsDeveloping.spec.tsx.snap create mode 100644 web/src/components/__tests__/__snapshots__/PillTabs.spec.tsx.snap diff --git a/package.json b/package.json index 706f6405..535abe36 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "gulp-sort": "^2.0.0", "husky": "^7.0.0", "i18next-scanner": "^3.0.0", + "identity-obj-proxy": "^3.0.0", "jest": "^27.0.6", "lint-staged": "^11.0.0", "prettier": "^2.3.2", diff --git a/web/src/components/__tests__/AlertErrorView.spec.tsx b/web/src/components/__tests__/AlertErrorView.spec.tsx new file mode 100644 index 00000000..6314e11f --- /dev/null +++ b/web/src/components/__tests__/AlertErrorView.spec.tsx @@ -0,0 +1,10 @@ +import { render } from '@testing-library/react'; +import React from 'react'; +import { AlertErrorView } from '../AlertErrorView'; + +describe('AlertErrorView', () => { + test('render', () => { + const wrapper = render(); + expect(wrapper.container).toMatchSnapshot(); + }); +}); diff --git a/web/src/components/__tests__/Highlight.spec.tsx b/web/src/components/__tests__/Highlight.spec.tsx new file mode 100644 index 00000000..ad4efefa --- /dev/null +++ b/web/src/components/__tests__/Highlight.spec.tsx @@ -0,0 +1,10 @@ +import { render } from '@testing-library/react'; +import React from 'react'; +import { Highlight } from '../Highlight'; + +describe('Highlight', () => { + test('render', () => { + const wrapper = render(Any Text); + expect(wrapper.container).toMatchSnapshot(); + }); +}); diff --git a/web/src/components/__tests__/IconBtn.spec.tsx b/web/src/components/__tests__/IconBtn.spec.tsx new file mode 100644 index 00000000..547f9fab --- /dev/null +++ b/web/src/components/__tests__/IconBtn.spec.tsx @@ -0,0 +1,10 @@ +import { render } from '@testing-library/react'; +import React from 'react'; +import { IconBtn } from '../IconBtn'; + +describe('IconBtn', () => { + test('render', () => { + const wrapper = render(); + expect(wrapper.container).toMatchSnapshot(); + }); +}); diff --git a/web/src/components/__tests__/IsDeveloping.spec.tsx b/web/src/components/__tests__/IsDeveloping.spec.tsx new file mode 100644 index 00000000..d19fc5ef --- /dev/null +++ b/web/src/components/__tests__/IsDeveloping.spec.tsx @@ -0,0 +1,10 @@ +import { render } from '@testing-library/react'; +import React from 'react'; +import { IsDeveloping } from '../IsDeveloping'; + +describe('IsDeveloping', () => { + test('render', () => { + const wrapper = render(); + expect(wrapper.container).toMatchSnapshot(); + }); +}); diff --git a/web/src/components/__tests__/PillTabs.spec.tsx b/web/src/components/__tests__/PillTabs.spec.tsx new file mode 100644 index 00000000..8d59023f --- /dev/null +++ b/web/src/components/__tests__/PillTabs.spec.tsx @@ -0,0 +1,19 @@ +import { render } from '@testing-library/react'; +import React from 'react'; +import { PillTabs, PillTabPane } from '../PillTabs'; + +describe('PillTabs', () => { + test('render', () => { + const wrapper = render( + + + 1 + + + 2 + + + ); + expect(wrapper.container).toMatchSnapshot(); + }); +}); diff --git a/web/src/components/__tests__/__snapshots__/AlertErrorView.spec.tsx.snap b/web/src/components/__tests__/__snapshots__/AlertErrorView.spec.tsx.snap new file mode 100644 index 00000000..611c0702 --- /dev/null +++ b/web/src/components/__tests__/__snapshots__/AlertErrorView.spec.tsx.snap @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AlertErrorView render 1`] = ` +
+ +
+`; diff --git a/web/src/components/__tests__/__snapshots__/Highlight.spec.tsx.snap b/web/src/components/__tests__/__snapshots__/Highlight.spec.tsx.snap new file mode 100644 index 00000000..86821e66 --- /dev/null +++ b/web/src/components/__tests__/__snapshots__/Highlight.spec.tsx.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Highlight render 1`] = ` +
+ + Any Text + +
+`; diff --git a/web/src/components/__tests__/__snapshots__/IconBtn.spec.tsx.snap b/web/src/components/__tests__/__snapshots__/IconBtn.spec.tsx.snap new file mode 100644 index 00000000..469af476 --- /dev/null +++ b/web/src/components/__tests__/__snapshots__/IconBtn.spec.tsx.snap @@ -0,0 +1,12 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`IconBtn render 1`] = ` +
+ +
+`; diff --git a/web/src/components/__tests__/__snapshots__/IsDeveloping.spec.tsx.snap b/web/src/components/__tests__/__snapshots__/IsDeveloping.spec.tsx.snap new file mode 100644 index 00000000..be9664e2 --- /dev/null +++ b/web/src/components/__tests__/__snapshots__/IsDeveloping.spec.tsx.snap @@ -0,0 +1,16 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`IsDeveloping render 1`] = ` +
+
+ +

+ 该功能暂未开放 +

+
+
+`; diff --git a/web/src/components/__tests__/__snapshots__/PillTabs.spec.tsx.snap b/web/src/components/__tests__/__snapshots__/PillTabs.spec.tsx.snap new file mode 100644 index 00000000..87790589 --- /dev/null +++ b/web/src/components/__tests__/__snapshots__/PillTabs.spec.tsx.snap @@ -0,0 +1,117 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PillTabs render 1`] = ` +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+
+ 1 +
+ +
+
+
+`; diff --git a/yarn.lock b/yarn.lock index f9a64983..d667f42d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4225,6 +4225,11 @@ hard-rejection@^2.1.0: resolved "https://registry.yarnpkg.com/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883" integrity sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA== +harmony-reflect@^1.4.6: + version "1.6.2" + resolved "https://registry.npmjs.org/harmony-reflect/-/harmony-reflect-1.6.2.tgz#31ecbd32e648a34d030d86adb67d4d47547fe710" + integrity sha512-HIp/n38R9kQjDEziXyDTuW3vvoxxyxjxFzXLrBr18uB47GnSt+G9D29fqrpM5ZkspMcPICud3XsBJQ4Y2URg8g== + has-ansi@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" @@ -4562,6 +4567,13 @@ icss-utils@^5.0.0, icss-utils@^5.1.0: resolved "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz#c6be6858abd013d768e98366ae47e25d5887b1ae" integrity sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA== +identity-obj-proxy@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz#94d2bda96084453ef36fbc5aaec37e0f79f1fc14" + integrity sha1-lNK9qWCERT7zb7xarsN+D3nx/BQ= + dependencies: + harmony-reflect "^1.4.6" + ieee754@^1.1.13: version "1.2.1" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"