TAILIEUCHUNG - Test Driven JavaScript Development- P22

Test Driven JavaScript Development- P22: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. | The Message List 413 Listing Expecting setModel to observe the message channel TestCase MessageListControllerSetModelTest test should observe model s message channel function var controller listController var model observe stubFn model assert assertEquals message 0 assertFunction 1 The test fails and Listing helps passing it by making the call to observe. Listing Calling observe function setModel model message function Next we ll expect the handler to be a bound addMessage method much like we did with the DOM event handler in the user form controller. Listing shows the test. Listing Expecting a bound addMessage as message handler TestCase MessageListControllerSetModelTest setUp function listController observe stubFn . test should observe with bound addMessage function var stub stubFn 1 assert Please purchase PDF Split-Merge on to remove this watermark. From the Library of 414 TDD and DOM Manipulation The Chat Client assertSame I jumped the gun slightly on this one immediately recognizing that a setup was required to avoid duplicating the test setup code. The test should look eerily familiar because it basically mimics the test we wrote to verify that userFormController observed the submit event with a bound handleSubmit method. Listing adds the correct handler to . What are your expectations as to the result of running the tests Listing Observing the message channel with a bound method function setModel model message this If you expected the test to pass but the previous test to fail then you re absolutely right. As before we need to add the method we re binding to the .

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.