TAILIEUCHUNG - Phát triển Javascript - part 42

Tham khảo tài liệu 'phát triển javascript - part 42', 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ả | Returning to the Controller 383 0 201 should close connection function test 201 We can pass these tests by copying the two lines we last added to post into the new respond method as Listing shows. Listing A dedicated respond method var chatRoomController . respond function status status Now we can simplify the post method by calling this method instead. Doing so also allows us to merge the original tests for status code and connection closing by stubbing respond and asserting that it was called. Formatting Messages Next up for the get method is properly formatting messages. Again we ll need to lean on the cometClient which defines the data format. The method should respond with a JSON object whose properties name the topic and values are arrays of objects. Additionally the JSON object should include a token property. The JSON string should be written to the response body. We can formulate this as a test by stubbing respond as we did before this time expecting an object passed as the second argument. Thus we will need to embellish respond later having it write its second argument to the response body as a JSON string. Listing shows the test. Download from 384 Server-Side JavaScript with Listing Expecting an object passed to respond function controllerSetUp var req new EventEmitter x-access-token . var add new Promised var wait new Promised addMessage stub add waitForMessagesSince stub wait . . testCase exports . should respond with formatted data function test stub var messages user cjno message hi messages

TỪ KHÓA LIÊN QUAN
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.