- fiddle will be loaded in different browser window/tab.
HTML
/* * Implement a function that returns the summary of the current user's latest conversations, * sorted by the latest message's timestamp (most recent conversation first). * * Make sure to have good unit tests in addition to the provided integration test! * * You have the following REST API available (base URL provided as a constant): * * Get current user's conversations: GET /conversations * Get messages in a conversation: GET /conversations/:conversation_id/messages * Get user by ID: GET /users/:user_id * * The result should be an array of objects of the following shape/type: * { * id : string; * latest_message: { * body : string; * from_user : { * id: string; * avatar_url: string; * }; * created_at : ISOString; * }; * } * */ const API_BASE_URL = "https://rechomework.prd.mz.internal.unity3d.com/api"; async function getRecentConversationSummaries () { // TODO: Implement this } // Configure Mocha, telling both it and chai to use BDD-style tests. mocha.setup("bdd"); chai.should(); describe('getRecentConversationSummaries()', () => { it('should return the current user\'s latest conversations sorted by latest message\'s timestamp', async () => { const result = await getRecentConversationSummaries(); result.should.deep.equal([ { id: "1", latest_message: { id: "1", body: "Moi!", from_user: { id: "1", avatar_url: "http://placekitten.com/g/300/300", }, created_at: "2016-08-25T10:15:00.670Z", }, }, { id: "2", latest_message: { id: "2", body: "Hello!", from_user: { id: "3", avatar_url: "http://placekitten.com/g/302/302", }, created_at: "2016-08-24T10:15:00.670Z", }, }, { id: "3", latest_message: { id: "3", body: "Hi!", from_user: { id: "1", avatar_url: "http://placekitten.com/g/300/300", }, created_at: "2016-08-23T10:15:00.670Z", }, }, { id: "4", latest_message: { id: "4", body: "Morning!", from_user: { id: "5", avatar_url: "http://placekitten.com/g/304/304", }, created_at: "2016-08-22T10:15:00.670Z", }, }, { id: "5", latest_message: { id: "5", body: "Pleep!", from_user: { id: "6", avatar_url: "http://placekitten.com/g/305/305", }, created_at: "2016-08-21T10:15:00.670Z", }, }, ]); }); // TODO: Add more tests }); // Run all our test suites. Only necessary in the browser. mocha.run();
Title:
Description:
descr
Resources (comma separated, no spaces):
https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.13.0/polyfill.js,https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.15.0/lodash.js,https://cdnjs.cloudflare.com/ajax/libs/mocha/3.0.2/mocha.js,https://cdnjs.cloudflare.com/ajax/libs/mocha/3.0.2/mocha.css,https://cdnjs.cloudflare.com/ajax/libs/chai/3.5.0/chai.js
DTD:
Wrap (l/d/h/b)