Đang chuẩn bị liên kết để tải về tài liệu:
Test Driven JavaScript Development- P21

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Test Driven JavaScript Development- P21:This book is about programming JavaScript for the real world, using the techniques and workflow suggested by Test-Driven Development. It is about gaining confidence in your code through test coverage, and gaining the ability to fearlessly refactor and organically evolve your code base. It is about writing modular and testable code. It is about writing JavaScript that works in a wide variety of environments and that doesn’t get in your user’s way. | 15.2 The User Form 393 The next test shown in Listing 15.5 expects setView to be a function. Listing 15.5 Expecting setview to be a function test should have setView method function assertFunction userController.setView Listing 15.6 adds an empty method to pass the test. Listing 15.6 Adding an empty setview method function function setView element tddjs.namespace chat .userFormController setview setview 15.2.1.2 Adding a Class The first actual behavior we ll test for is that the js-chat class name is added to the DOM element as seen in Listing 15.7. Note that the test requires the Object.create implementation from Chapter 7 Objects and Prototypal Inheritance in lib object.js to run smoothly across browsers. Listing 15.7 Expecting the view to have its class name set TestCase UserFormControllerSetViewTest test should add js-chat class function var controller Object.create userController var element controller.setView element assertClassName js-chat element The first thing that sticks out about this test is that it contains no DOM elements. It does however use the assertClassName assertion which checks if an element has the given class name. This assertion is generic and only checks that the object defines a string property className and that one of its space separated values matches the provided string. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. From the Library of WoweBook.Com 394 TDD and DOM Manipulation The Chat Client The element object is a simple stub object. At this point there s no need to use a real DOM element because all we want to check is that some property was assigned. The test fails and Listing 15.8 assigns the class name to pass it. Listing 15.8 Adding the class function setView element element.className js-chat At this point you might worry about a few things. Should we really be overriding the class name like that Should the class name not be configurable Remember You ain t gonna need it At this point we have no .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.