Skip to content

Commit 8bef8a1

Browse files
started chapter 3
1 parent 53f041d commit 8bef8a1

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

readme-pr-fr.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ beforeEach(() => {
10601060

10611061
```javascript
10621062
test('هنگامی که سرویس کاربران یک بار با 503 پاسخ می دهد و مکانیسم امتحان مجدد اعمال می شود، سفارش با موفقیت اضافه می شود', async () => {
1063-
//مفدار دهی کردن
1063+
//مقدار دهی کردن
10641064
nock.removeInterceptor(userServiceNock.interceptors[0])
10651065
nock('http://localhost/user/')
10661066
.get('/1')
@@ -1104,54 +1104,54 @@ beforeEach(() => {
11041104

11051105
<br/><br/>
11061106

1107-
# Section 3️⃣: Frontend Testing
1107+
# بخش 3️⃣: Frontend تست کردن
11081108

1109-
## ⚪ ️ 3.1 Separate UI from functionality
1109+
## ⚪ ️ 3.1 UI را از لاجیک برنامه جدا کنید
11101110

1111-
:white_check_mark: **Do:** When focusing on testing component logic, UI details become a noise that should be extracted, so your tests can focus on pure data. Practically, extract the desired data from the markup in an abstract way that is not too coupled to the graphic implementation, assert only on pure data (vs HTML/CSS graphic details) and disable animations that slow down. You might get tempted to avoid rendering and test only the back part of the UI (e.g. services, actions, store) but this will result in fictional tests that don't resemble the reality and won't reveal cases where the right data doesn't even arrive in the UI
1111+
:white_check_mark: **انجام دادن:** هنگام تمرکز بر روی تست منطق مؤلفه، جزئیات UI تبدیل به نویز می شود که باید استخراج شود، بنابراین آزمایشات شما می توانند بر روی داده های خالص تمرکز کنند. عملاً داده‌های مورد نظر را از نشانه‌گذاری به روشی انتزاعی استخراج کنید که خیلی با پیاده‌سازی گرافیکی همراه نباشد، فقط روی داده‌های خالص (در مقابل جزئیات گرافیکی HTML/CSS) ادعا کنید و انیمیشن‌هایی را که کند می‌شوند غیرفعال کنید. ممکن است وسوسه شوید که از رندر کردن خودداری کنید و فقط قسمت پشتی رابط کاربری (مانند سرویس‌ها، اقدامات، فروشگاه) را آزمایش کنید، اما این منجر به آزمایش‌های تخیلی می‌شود که به واقعیت شباهت ندارند و مواردی را که داده‌های مناسب وجود ندارد را نشان نمی‌دهد. حتی وارد UI شوید
11121112

11131113
<br/>
11141114

1115-
**Otherwise:** The pure calculated data of your test might be ready in 10ms, but then the whole test will last 500ms (100 tests = 1 min) due to some fancy and irrelevant animation
1115+
**در غیر این صورت:** داده‌های محاسباتی خالص آزمون شما ممکن است در 10 میلی‌ثانیه آماده باشد، اما پس از آن کل آزمون به دلیل برخی انیمیشن‌های فانتزی و نامربوط، 500 میلی‌ثانیه (100 تست = 1 دقیقه) طول خواهد کشید.
11161116

11171117
<br/>
11181118

1119-
<details><summary>✏ <b>Code Examples</b></summary>
1119+
<details><summary>✏ <b>نمونه کد</b></summary>
11201120

11211121
<br/>
11221122

1123-
### :clap: Doing It Right Example: Separating out the UI details
1123+
### :clap: متال درست: جدا کردن جزئیات UI
11241124

11251125
![](https://img.shields.io/badge/🔧%20Example%20using%20React-blue.svg "Examples with React") ![](https://img.shields.io/badge/🔧%20Example%20using%20React%20Testing%20Library-blue.svg "Examples with react-testing-library")
11261126

11271127
```javascript
1128-
test("When users-list is flagged to show only VIP, should display only VIP members", () => {
1129-
// Arrange
1128+
test("هنگامی که لیست کاربران برای نشان دادن فقط VIP پرچم گذاری می شود، باید فقط اعضای VIP نمایش داده شود", () => {
1129+
// مقدار دهی کردن
11301130
const allUsers = [{ id: 1, name: "Yoni Goldberg", vip: false }, { id: 2, name: "John Doe", vip: true }];
11311131

1132-
// Act
1132+
// اجرا کردن
11331133
const { getAllByTestId } = render(<UsersList users={allUsers} showOnlyVIP={true} />);
11341134

1135-
// Assert - Extract the data from the UI first
1135+
// مفایسه کردن - ابتدا داده ها را از UI استخراج کنید
11361136
const allRenderedUsers = getAllByTestId("user").map(uiElement => uiElement.textContent);
11371137
const allRealVIPUsers = allUsers.filter(user => user.vip).map(user => user.name);
1138-
expect(allRenderedUsers).toEqual(allRealVIPUsers); //compare data with data, no UI here
1138+
expect(allRenderedUsers).toEqual(allRealVIPUsers); //داده ها را با داده ها مقایسه کنید، اینجا رابط کاربری وجود ندارد
11391139
});
11401140
```
11411141

11421142
<br/>
11431143

1144-
### :thumbsdown: Anti-Pattern Example: Assertion mix UI details and data
1144+
### :thumbsdown: مثال ضد الگو: جزئیات و داده های رابط کاربری ترکیبی ادعا
11451145

11461146
```javascript
1147-
test("When flagging to show only VIP, should display only VIP members", () => {
1148-
// Arrange
1147+
test("هنگام پرچم گذاری برای نمایش فقط VIP، باید فقط اعضای VIP نمایش داده شود", () => {
1148+
// مقداری دهی کردن
11491149
const allUsers = [{ id: 1, name: "Yoni Goldberg", vip: false }, { id: 2, name: "John Doe", vip: true }];
11501150

1151-
// Act
1151+
// اجرا کردن
11521152
const { getAllByTestId } = render(<UsersList users={allUsers} showOnlyVIP={true} />);
11531153

1154-
// Assert - Mix UI & data in assertion
1154+
// مقابسه کردن - ترکیب ui و data در این قسمت
11551155
expect(getAllByTestId("user")).toEqual('[<li data-test-id="user">John Doe</li>]');
11561156
});
11571157
```

0 commit comments

Comments
 (0)