tailieunhanh - Phát triển Javascript - part 43

Tham khảo tài liệu 'phát triển javascript - part 43', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | The User Form 393 The next test shown in Listing expects setView to be a function. Listing Expecting setview to be a function test should have setView method function assertFunction Listing adds an empty method to pass the test. Listing Adding an empty setview method function function setView element chat .userFormController setview setview 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 . Note that the test requires the implementation from Chapter 7 Objects and Prototypal Inheritance in lib to run smoothly across browsers. Listing Expecting the view to have its class name set TestCase UserFormControllerSetViewTest test should add js-chat class function var controller userController var element 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. Download from 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 assigns the class name to pass it. Listing Adding the class function setView element 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 use case demonstrating the need to use an element that already has class names or

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.