![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Mocking framework for Laravel Echo
npm i mock-echo
Import mock-echo
import MockEcho from 'mock-echo'
Replace global object Echo
with new MockEcho()
before every unit test
let mockEcho
beforeEach(() => {
mockEcho = new MockEcho()
global.Echo = mockEcho
})
Remember to delete global object Echo
after every unit test
afterEach(() => {
delete global.Echo
})
You can use channelExist
, privateChannelExist
or presenceChannelExist
to determine whether channel has been listened:
channelExist
: channelprivateChannelExist
: private channelpresenceChannelExist
: presence channelExample:
expect(mockEcho.channelExist('news')).toBe(true)
expect(mockEcho.privateChannelExist('meeting')).toBe(true)
expect(mockEcho.presenceChannelExist('chat')).toBe(true)
All examples are using
expect
as assertion library
You can use getChannel
, getPrivateChannel
, getPresenceChannel
to get mock channel object
getChannel
: channelgetPrivateChannel
: private channelgetPresenceChannel
: presence channelMock channel object has functions eventExist
, broadcast
, etc.
Example:
expect(mockEcho.getChannel('news').eventExist('NewsMessage')).toBe(true)
You can use getChannel(channelName).eventExist
, getPrivateChannel(channelName).eventExist
or getPresenceChannel(channelName).eventExist
to determine whether event has been listened:
getChannel(channelName).eventExist
: channelgetPrivateChannel(channelName).eventExist
: private channelgetPresenceChannel(channelName).eventExist
: presence channelExample:
expect(mockEcho.getChannel('news').eventExist('NewsMessage')).toBe(true)
expect(mockEcho.getPrivateChannel('meeting').eventExist('MeetingMessage')).toBe(true)
expect(mockEcho.getPresenceChannel('chat').eventExist('ChatMessage')).toBe(true)
You can use broadcast
to broadcast an event.
Note: If you are using
vue-test-utils
, call$nextTick
before assertion.
Example:
mockEcho.getChannel('news').broadcast('NewsMessage', { message: 'Hello World' })
wrapper.vm.$nextTick(() => {
expect(wrapper.find('.message').text()).toBe('It said Hello World')
done()
})
You can use iJoin
, userJoin
, userLeave
to trigger presence channel actions:
iJoin
: trigger here
listeneruserJoin
: trigger joining
listner. It will return subId
after calling userJoin
. You can use this subId
to get this user away from this channel.userLeave
: trigger leaving
listner. Use subId
which got from userJoin
to get this user away from this channel.Note: If you are using
vue-test-utils
, call$nextTick
before assertion.
Example:
mockEcho.getPresenceChannel('chat').iJoin({id: 1, name: 'Alex'})
wrapper.vm.$nextTick(() => {
expect(wrapper.find('.here-message').text()).toBe('There are 1 users')
done()
})
// You will need paulSubId to get this user away from this channel
let paulSubId = mockEcho.getPresenceChannel('chat').userJoin({id: 2, name: 'Paul'})
wrapper.vm.$nextTick(() => {
expect(wrapper.find('.join-message').text()).toBe('Paul joined')
done()
})
mockEcho.getPresenceChannel('chat').userLeave(paulSubId)
wrapper.vm.$nextTick(() => {
expect(wrapper.find('.leave-message').text()).toBe('Paul leaved')
done()
})
You can use whisper
to send user event. Only private channel object and presence channel object have whisper
.
Note: If you are using
vue-test-utils
, call$nextTick
before assertion.
Example:
// private channel
mockEcho.getPrivateChannel('meeting').whisper('meetingClicking', { username: username })
wrapper.vm.$nextTick(() => {
expect(wrapper.find('.whisper-message').text()).toBe(`${username} is clicking the button`)
done()
})
// presence channel
mockEcho.getPresenceChannel('chat').whisper('chatClicking', { username: username })
wrapper.vm.$nextTick(() => {
expect(wrapper.find('.whisper-message').text()).toBe(`${username} is clicking the button`)
done()
})
Please create the issue
可以用中文
FAQs
Mocking framework for Laravel Echo
The npm package mock-echo receives a total of 489 weekly downloads. As such, mock-echo popularity was classified as not popular.
We found that mock-echo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.