mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
} from '../../../helpers/render-with-context'
|
||||
import { stubMathJax, tearDownMathJaxStubs } from './stubs'
|
||||
|
||||
describe('<ChatPane />', function() {
|
||||
describe('<ChatPane />', function () {
|
||||
const user = {
|
||||
id: 'fake_user',
|
||||
first_name: 'fake_user_first_name',
|
||||
@@ -32,18 +32,18 @@ describe('<ChatPane />', function() {
|
||||
}
|
||||
]
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
fetchMock.reset()
|
||||
cleanUpContext()
|
||||
|
||||
stubMathJax()
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
tearDownMathJaxStubs()
|
||||
})
|
||||
|
||||
it('renders multiple messages', async function() {
|
||||
it('renders multiple messages', async function () {
|
||||
fetchMock.get(/messages/, testMessages)
|
||||
|
||||
renderWithChatContext(<ChatPane />, { user })
|
||||
@@ -52,7 +52,7 @@ describe('<ChatPane />', function() {
|
||||
await screen.findByText('another message')
|
||||
})
|
||||
|
||||
it('A loading spinner is rendered while the messages are loading, then disappears', async function() {
|
||||
it('A loading spinner is rendered while the messages are loading, then disappears', async function () {
|
||||
fetchMock.get(/messages/, [])
|
||||
|
||||
renderWithChatContext(<ChatPane />, { user })
|
||||
@@ -60,8 +60,8 @@ describe('<ChatPane />', function() {
|
||||
await waitForElementToBeRemoved(() => screen.getByText('Loading…'))
|
||||
})
|
||||
|
||||
describe('"send your first message" placeholder', function() {
|
||||
it('is rendered when there are no messages ', async function() {
|
||||
describe('"send your first message" placeholder', function () {
|
||||
it('is rendered when there are no messages ', async function () {
|
||||
fetchMock.get(/messages/, [])
|
||||
|
||||
renderWithChatContext(<ChatPane />, { user })
|
||||
@@ -69,7 +69,7 @@ describe('<ChatPane />', function() {
|
||||
await screen.findByText('Send your first message to your collaborators')
|
||||
})
|
||||
|
||||
it('is not rendered when messages are displayed', function() {
|
||||
it('is not rendered when messages are displayed', function () {
|
||||
fetchMock.get(/messages/, testMessages)
|
||||
|
||||
renderWithChatContext(<ChatPane />, { user })
|
||||
|
||||
@@ -5,15 +5,15 @@ import { screen, render, fireEvent } from '@testing-library/react'
|
||||
|
||||
import MessageInput from '../../../../../frontend/js/features/chat/components/message-input'
|
||||
|
||||
describe('<MessageInput />', function() {
|
||||
describe('<MessageInput />', function () {
|
||||
let resetUnreadMessages, sendMessage
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
resetUnreadMessages = sinon.stub()
|
||||
sendMessage = sinon.stub()
|
||||
})
|
||||
|
||||
it('renders successfully', function() {
|
||||
it('renders successfully', function () {
|
||||
render(
|
||||
<MessageInput
|
||||
sendMessage={sendMessage}
|
||||
@@ -24,7 +24,7 @@ describe('<MessageInput />', function() {
|
||||
screen.getByLabelText('Your Message')
|
||||
})
|
||||
|
||||
it('sends a message after typing and hitting enter', function() {
|
||||
it('sends a message after typing and hitting enter', function () {
|
||||
render(
|
||||
<MessageInput
|
||||
sendMessage={sendMessage}
|
||||
@@ -40,7 +40,7 @@ describe('<MessageInput />', function() {
|
||||
expect(sendMessage).to.be.calledWith('hello world')
|
||||
})
|
||||
|
||||
it('resets the number of unread messages after clicking on the input', function() {
|
||||
it('resets the number of unread messages after clicking on the input', function () {
|
||||
render(
|
||||
<MessageInput
|
||||
sendMessage={sendMessage}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { screen, render, fireEvent } from '@testing-library/react'
|
||||
import MessageList from '../../../../../frontend/js/features/chat/components/message-list'
|
||||
import { stubMathJax, tearDownMathJaxStubs } from './stubs'
|
||||
|
||||
describe('<MessageList />', function() {
|
||||
describe('<MessageList />', function () {
|
||||
const currentUser = {
|
||||
id: 'fake_user',
|
||||
first_name: 'fake_user_first_name',
|
||||
@@ -30,15 +30,15 @@ describe('<MessageList />', function() {
|
||||
]
|
||||
}
|
||||
|
||||
before(function() {
|
||||
before(function () {
|
||||
stubMathJax()
|
||||
})
|
||||
|
||||
after(function() {
|
||||
after(function () {
|
||||
tearDownMathJaxStubs()
|
||||
})
|
||||
|
||||
it('renders multiple messages', function() {
|
||||
it('renders multiple messages', function () {
|
||||
render(
|
||||
<MessageList
|
||||
userId={currentUser.id}
|
||||
@@ -51,7 +51,7 @@ describe('<MessageList />', function() {
|
||||
screen.getByText('another message')
|
||||
})
|
||||
|
||||
it('renders a single timestamp for all messages within 5 minutes', function() {
|
||||
it('renders a single timestamp for all messages within 5 minutes', function () {
|
||||
const msgs = createMessages()
|
||||
msgs[0].timestamp = new Date(2019, 6, 3, 4, 23).getTime()
|
||||
msgs[1].timestamp = new Date(2019, 6, 3, 4, 27).getTime()
|
||||
@@ -68,7 +68,7 @@ describe('<MessageList />', function() {
|
||||
expect(screen.queryByText('4:27 am Wed, 3rd Jul 19')).to.not.exist
|
||||
})
|
||||
|
||||
it('renders a timestamp for each messages separated for more than 5 minutes', function() {
|
||||
it('renders a timestamp for each messages separated for more than 5 minutes', function () {
|
||||
const msgs = createMessages()
|
||||
msgs[0].timestamp = new Date(2019, 6, 3, 4, 23).getTime()
|
||||
msgs[1].timestamp = new Date(2019, 6, 3, 4, 31).getTime()
|
||||
@@ -85,7 +85,7 @@ describe('<MessageList />', function() {
|
||||
screen.getByText('4:31 am Wed, 3rd Jul 19')
|
||||
})
|
||||
|
||||
it('resets the number of unread messages after clicking on the input', function() {
|
||||
it('resets the number of unread messages after clicking on the input', function () {
|
||||
const resetUnreadMessages = sinon.stub()
|
||||
render(
|
||||
<MessageList
|
||||
|
||||
@@ -5,24 +5,24 @@ import { render, screen } from '@testing-library/react'
|
||||
import Message from '../../../../../frontend/js/features/chat/components/message'
|
||||
import { stubMathJax, tearDownMathJaxStubs } from './stubs'
|
||||
|
||||
describe('<Message />', function() {
|
||||
describe('<Message />', function () {
|
||||
const currentUser = {
|
||||
id: 'fake_user',
|
||||
first_name: 'fake_user_first_name',
|
||||
email: 'fake@example.com'
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
window.user = currentUser
|
||||
stubMathJax()
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
delete window.user
|
||||
tearDownMathJaxStubs()
|
||||
})
|
||||
|
||||
it('renders a basic message', function() {
|
||||
it('renders a basic message', function () {
|
||||
const message = {
|
||||
contents: ['a message'],
|
||||
user: currentUser
|
||||
@@ -33,7 +33,7 @@ describe('<Message />', function() {
|
||||
screen.getByText('a message')
|
||||
})
|
||||
|
||||
it('renders a message with multiple contents', function() {
|
||||
it('renders a message with multiple contents', function () {
|
||||
const message = {
|
||||
contents: ['a message', 'another message'],
|
||||
user: currentUser
|
||||
@@ -45,7 +45,7 @@ describe('<Message />', function() {
|
||||
screen.getByText('another message')
|
||||
})
|
||||
|
||||
it('renders HTML links within messages', function() {
|
||||
it('renders HTML links within messages', function () {
|
||||
const message = {
|
||||
contents: [
|
||||
'a message with a <a href="https://overleaf.com">link to Overleaf</a>'
|
||||
@@ -58,13 +58,13 @@ describe('<Message />', function() {
|
||||
screen.getByRole('link', { name: 'https://overleaf.com' })
|
||||
})
|
||||
|
||||
describe('when the message is from the user themselves', function() {
|
||||
describe('when the message is from the user themselves', function () {
|
||||
const message = {
|
||||
contents: ['a message'],
|
||||
user: currentUser
|
||||
}
|
||||
|
||||
it('does not render the user name nor the email', function() {
|
||||
it('does not render the user name nor the email', function () {
|
||||
render(<Message userId={currentUser.id} message={message} />)
|
||||
|
||||
expect(screen.queryByText(currentUser.first_name)).to.not.exist
|
||||
@@ -72,7 +72,7 @@ describe('<Message />', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the message is from other user', function() {
|
||||
describe('when the message is from other user', function () {
|
||||
const otherUser = {
|
||||
id: 'other_user',
|
||||
first_name: 'other_user_first_name'
|
||||
@@ -83,13 +83,13 @@ describe('<Message />', function() {
|
||||
user: otherUser
|
||||
}
|
||||
|
||||
it('should render the other user name', function() {
|
||||
it('should render the other user name', function () {
|
||||
render(<Message userId={currentUser.id} message={message} />)
|
||||
|
||||
screen.getByText(otherUser.first_name)
|
||||
})
|
||||
|
||||
it('should render the other user email when their name is not available', function() {
|
||||
it('should render the other user email when their name is not available', function () {
|
||||
const msg = {
|
||||
contents: message.contents,
|
||||
user: {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
MESSAGE_LIMIT
|
||||
} from '../../../../../frontend/js/features/chat/store/chat-store'
|
||||
|
||||
describe('ChatStore', function() {
|
||||
describe('ChatStore', function () {
|
||||
let store, socket, mockSocketMessage
|
||||
|
||||
const user = {
|
||||
@@ -22,7 +22,7 @@ describe('ChatStore', function() {
|
||||
user
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
fetchMock.reset()
|
||||
|
||||
window.csrfToken = 'csrf_tok'
|
||||
@@ -34,7 +34,7 @@ describe('ChatStore', function() {
|
||||
store = new ChatStore(user, testProjectId)
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
fetchMock.restore()
|
||||
delete window._ide
|
||||
delete window.csrfToken
|
||||
@@ -42,19 +42,19 @@ describe('ChatStore', function() {
|
||||
delete window.project_id
|
||||
})
|
||||
|
||||
describe('new message events', function() {
|
||||
it('subscribes to the socket for new message events', function() {
|
||||
describe('new message events', function () {
|
||||
it('subscribes to the socket for new message events', function () {
|
||||
expect(socket.on).to.be.calledWith('new-chat-message')
|
||||
})
|
||||
|
||||
it('notifies an update event after new messages are received', function() {
|
||||
it('notifies an update event after new messages are received', function () {
|
||||
const subscriber = sinon.stub()
|
||||
store.on('updated', subscriber)
|
||||
mockSocketMessage(testMessage)
|
||||
expect(subscriber).to.be.calledOnce
|
||||
})
|
||||
|
||||
it('can unsubscribe from events', function() {
|
||||
it('can unsubscribe from events', function () {
|
||||
const subscriber = sinon.stub()
|
||||
store.on('updated', subscriber)
|
||||
store.off('updated', subscriber)
|
||||
@@ -62,7 +62,7 @@ describe('ChatStore', function() {
|
||||
expect(subscriber).not.to.be.called
|
||||
})
|
||||
|
||||
it('when the message is from other user, it is added to the messages list', function() {
|
||||
it('when the message is from other user, it is added to the messages list', function () {
|
||||
mockSocketMessage({ ...testMessage, id: 'other_user_msg' })
|
||||
expect(store.messages[store.messages.length - 1]).to.deep.equal({
|
||||
id: 'other_user_msg',
|
||||
@@ -72,12 +72,12 @@ describe('ChatStore', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('messages sent by the user', function() {
|
||||
beforeEach(function() {
|
||||
describe('messages sent by the user', function () {
|
||||
beforeEach(function () {
|
||||
fetchMock.post(/messages/, 204)
|
||||
})
|
||||
|
||||
it('are not added to the message list', async function() {
|
||||
it('are not added to the message list', async function () {
|
||||
await store.sendMessage(testMessage.content)
|
||||
const originalMessageList = store.messages.slice(0)
|
||||
mockSocketMessage(testMessage)
|
||||
@@ -100,7 +100,7 @@ describe('ChatStore', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it("don't notify an update event after new messages are received", async function() {
|
||||
it("don't notify an update event after new messages are received", async function () {
|
||||
await store.sendMessage(testMessage.content)
|
||||
|
||||
const subscriber = sinon.stub()
|
||||
@@ -110,22 +110,22 @@ describe('ChatStore', function() {
|
||||
expect(subscriber).not.to.be.called
|
||||
})
|
||||
|
||||
it("have an 'id' property", async function() {
|
||||
it("have an 'id' property", async function () {
|
||||
await store.sendMessage(testMessage.content)
|
||||
expect(typeof store.messages[0].id).to.equal('string')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('loadMoreMessages()', function() {
|
||||
it('aborts the request when the entire message list is loaded', async function() {
|
||||
describe('loadMoreMessages()', function () {
|
||||
it('aborts the request when the entire message list is loaded', async function () {
|
||||
store.atEnd = true
|
||||
await store.loadMoreMessages()
|
||||
expect(fetchMock.calls().length).to.equal(0)
|
||||
expect(store.loading).to.equal(false)
|
||||
})
|
||||
|
||||
it('updates the list of messages', async function() {
|
||||
it('updates the list of messages', async function () {
|
||||
const originalMessageList = store.messages.slice(0)
|
||||
fetchMock.get(/messages/, [testMessage])
|
||||
await store.loadMoreMessages()
|
||||
@@ -138,7 +138,7 @@ describe('ChatStore', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('notifies an update event for when the loading starts, and a second one once data is available', async function() {
|
||||
it('notifies an update event for when the loading starts, and a second one once data is available', async function () {
|
||||
const subscriber = sinon.stub()
|
||||
store.on('updated', subscriber)
|
||||
fetchMock.get(/messages/, [testMessage])
|
||||
@@ -146,14 +146,14 @@ describe('ChatStore', function() {
|
||||
expect(subscriber).to.be.calledTwice
|
||||
})
|
||||
|
||||
it('marks `atEnd` flag to true when there are no more messages to retrieve', async function() {
|
||||
it('marks `atEnd` flag to true when there are no more messages to retrieve', async function () {
|
||||
expect(store.atEnd).to.equal(false)
|
||||
fetchMock.get(/messages/, [testMessage])
|
||||
await store.loadMoreMessages()
|
||||
expect(store.atEnd).to.equal(true)
|
||||
})
|
||||
|
||||
it('marks `atEnd` flag to false when there are still messages to retrieve', async function() {
|
||||
it('marks `atEnd` flag to false when there are still messages to retrieve', async function () {
|
||||
const messages = []
|
||||
for (let i = 0; i < MESSAGE_LIMIT; i++) {
|
||||
messages.push({ ...testMessage, content: `message #${i}` })
|
||||
@@ -164,7 +164,7 @@ describe('ChatStore', function() {
|
||||
expect(store.atEnd).to.equal(false)
|
||||
})
|
||||
|
||||
it('subsequent requests for new messages start at the timestamp of the latest message', async function() {
|
||||
it('subsequent requests for new messages start at the timestamp of the latest message', async function () {
|
||||
const messages = []
|
||||
for (let i = 0; i < MESSAGE_LIMIT - 1; i++) {
|
||||
// sending enough messages so it doesn't mark `atEnd === true`
|
||||
@@ -186,12 +186,12 @@ describe('ChatStore', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('sendMessage()', function() {
|
||||
beforeEach(function() {
|
||||
describe('sendMessage()', function () {
|
||||
beforeEach(function () {
|
||||
fetchMock.post(/messages/, 204)
|
||||
})
|
||||
|
||||
it('appends the message to the list', async function() {
|
||||
it('appends the message to the list', async function () {
|
||||
const originalMessageList = store.messages.slice(0)
|
||||
await store.sendMessage('a message')
|
||||
expect(store.messages.length).to.equal(originalMessageList.length + 1)
|
||||
@@ -201,14 +201,14 @@ describe('ChatStore', function() {
|
||||
expect(lastMessage.timestamp).to.be.greaterThan(0)
|
||||
})
|
||||
|
||||
it('notifies an update event', async function() {
|
||||
it('notifies an update event', async function () {
|
||||
const subscriber = sinon.stub()
|
||||
store.on('updated', subscriber)
|
||||
await store.sendMessage('a message')
|
||||
expect(subscriber).to.be.calledOnce
|
||||
})
|
||||
|
||||
it('sends an http POST request to the server', async function() {
|
||||
it('sends an http POST request to the server', async function () {
|
||||
await store.sendMessage('a message')
|
||||
expect(fetchMock.calls().length).to.equal(1)
|
||||
const body = fetchMock.lastCall()[1].body
|
||||
@@ -218,7 +218,7 @@ describe('ChatStore', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('ignores empty messages', async function() {
|
||||
it('ignores empty messages', async function () {
|
||||
const subscriber = sinon.stub()
|
||||
store.on('updated', subscriber)
|
||||
await store.sendMessage('')
|
||||
@@ -227,12 +227,12 @@ describe('ChatStore', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('destroy', function() {
|
||||
beforeEach(function() {
|
||||
describe('destroy', function () {
|
||||
beforeEach(function () {
|
||||
fetchMock.post(/messages/, 204)
|
||||
})
|
||||
|
||||
it('removes event listeners', async function() {
|
||||
it('removes event listeners', async function () {
|
||||
const subscriber = sinon.stub()
|
||||
store.on('updated', subscriber)
|
||||
store.destroy()
|
||||
|
||||
@@ -29,7 +29,7 @@ function createTestMessageList() {
|
||||
]
|
||||
}
|
||||
|
||||
describe('prependMessages()', function() {
|
||||
describe('prependMessages()', function () {
|
||||
function createTestMessages() {
|
||||
const message1 = {
|
||||
id: 'prepended_message',
|
||||
@@ -41,7 +41,7 @@ describe('prependMessages()', function() {
|
||||
return [message1, message2]
|
||||
}
|
||||
|
||||
it('to an empty list', function() {
|
||||
it('to an empty list', function () {
|
||||
const messages = createTestMessages()
|
||||
expect(prependMessages([], messages)).to.deep.equal([
|
||||
{
|
||||
@@ -53,16 +53,16 @@ describe('prependMessages()', function() {
|
||||
])
|
||||
})
|
||||
|
||||
describe('when the messages to prepend are from the same user', function() {
|
||||
describe('when the messages to prepend are from the same user', function () {
|
||||
let list, messages
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
list = createTestMessageList()
|
||||
messages = createTestMessages()
|
||||
messages[0].user = testUser // makes all the messages have the same author
|
||||
})
|
||||
|
||||
it('when the prepended messages are close in time, contents should be merged into the same message', function() {
|
||||
it('when the prepended messages are close in time, contents should be merged into the same message', function () {
|
||||
const result = prependMessages(createTestMessageList(), messages)
|
||||
expect(result.length).to.equal(list.length + 1)
|
||||
expect(result[0]).to.deep.equal({
|
||||
@@ -73,7 +73,7 @@ describe('prependMessages()', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('when the prepended messages are separated in time, each message is prepended', function() {
|
||||
it('when the prepended messages are separated in time, each message is prepended', function () {
|
||||
messages[0].timestamp = messages[1].timestamp - 6 * 60 * 1000 // 6 minutes before the next message
|
||||
const result = prependMessages(createTestMessageList(), messages)
|
||||
expect(result.length).to.equal(list.length + 2)
|
||||
@@ -92,15 +92,15 @@ describe('prependMessages()', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the messages to prepend are from different users', function() {
|
||||
describe('when the messages to prepend are from different users', function () {
|
||||
let list, messages
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
list = createTestMessageList()
|
||||
messages = createTestMessages()
|
||||
})
|
||||
|
||||
it('should prepend separate messages to the list', function() {
|
||||
it('should prepend separate messages to the list', function () {
|
||||
messages[0].user = otherUser
|
||||
const result = prependMessages(createTestMessageList(), messages)
|
||||
expect(result.length).to.equal(list.length + 2)
|
||||
@@ -119,7 +119,7 @@ describe('prependMessages()', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should merge the prepended messages into the first existing one when user is same user and are close in time', function() {
|
||||
it('should merge the prepended messages into the first existing one when user is same user and are close in time', function () {
|
||||
const list = createTestMessageList()
|
||||
const messages = createTestMessages()
|
||||
messages[0].user = messages[1].user = list[0].user
|
||||
@@ -135,7 +135,7 @@ describe('prependMessages()', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('appendMessage()', function() {
|
||||
describe('appendMessage()', function () {
|
||||
function createTestMessage() {
|
||||
return {
|
||||
id: 'appended_message',
|
||||
@@ -145,7 +145,7 @@ describe('appendMessage()', function() {
|
||||
}
|
||||
}
|
||||
|
||||
it('to an empty list', function() {
|
||||
it('to an empty list', function () {
|
||||
const testMessage = createTestMessage()
|
||||
expect(appendMessage([], testMessage)).to.deep.equal([
|
||||
{
|
||||
@@ -157,17 +157,17 @@ describe('appendMessage()', function() {
|
||||
])
|
||||
})
|
||||
|
||||
describe('messages appended shortly after the last message on the list', function() {
|
||||
describe('messages appended shortly after the last message on the list', function () {
|
||||
let list, message
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
list = createTestMessageList()
|
||||
message = createTestMessage()
|
||||
message.timestamp = list[1].timestamp + 6 * 1000 // 6 seconds after the last message in the list
|
||||
})
|
||||
|
||||
describe('when the author is the same as the last message', function() {
|
||||
it('should append the content to the last message', function() {
|
||||
describe('when the author is the same as the last message', function () {
|
||||
it('should append the content to the last message', function () {
|
||||
const result = appendMessage(list, message)
|
||||
expect(result.length).to.equal(list.length)
|
||||
expect(result[1].contents).to.deep.equal(
|
||||
@@ -175,18 +175,18 @@ describe('appendMessage()', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should update the last message timestamp', function() {
|
||||
it('should update the last message timestamp', function () {
|
||||
const result = appendMessage(list, message)
|
||||
expect(result[1].timestamp).to.equal(message.timestamp)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the author is different than the last message', function() {
|
||||
beforeEach(function() {
|
||||
describe('when the author is different than the last message', function () {
|
||||
beforeEach(function () {
|
||||
message.user = otherUser
|
||||
})
|
||||
|
||||
it('should append the new message to the list', function() {
|
||||
it('should append the new message to the list', function () {
|
||||
const result = appendMessage(list, message)
|
||||
expect(result.length).to.equal(list.length + 1)
|
||||
expect(result[2]).to.deep.equal({
|
||||
@@ -199,16 +199,16 @@ describe('appendMessage()', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('messages appended later after the last message on the list', function() {
|
||||
describe('messages appended later after the last message on the list', function () {
|
||||
let list, message
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
list = createTestMessageList()
|
||||
message = createTestMessage()
|
||||
message.timestamp = list[1].timestamp + 6 * 60 * 1000 // 6 minutes after the last message in the list
|
||||
})
|
||||
|
||||
it('when the author is the same as the last message, should be appended as new message', function() {
|
||||
it('when the author is the same as the last message, should be appended as new message', function () {
|
||||
const result = appendMessage(list, message)
|
||||
expect(result.length).to.equal(3)
|
||||
expect(result[2]).to.deep.equal({
|
||||
@@ -219,7 +219,7 @@ describe('appendMessage()', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('when the author is the different than the last message, should be appended as new message', function() {
|
||||
it('when the author is the different than the last message, should be appended as new message', function () {
|
||||
message.user = otherUser
|
||||
|
||||
const result = appendMessage(list, message)
|
||||
|
||||
Reference in New Issue
Block a user