Skip to content

Commit e1f7edf

Browse files
author
Alex Yang
committed
update readme.md
1 parent 2e26eb0 commit e1f7edf

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

README.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ You can use `channelExist`, `privateChannelExist` or `presenceChannelExist` to d
4949

5050
Example:
5151
```javascript
52-
expect(mockEcho.channelExist('news')).toBe(true)
53-
expect(mockEcho.privateChannelExist('meeting')).toBe(true)
54-
expect(mockEcho.presenceChannelExist('chat')).toBe(true)
52+
expect(mockEcho.channelExist('news')).toBe(true)
53+
expect(mockEcho.privateChannelExist('meeting')).toBe(true)
54+
expect(mockEcho.presenceChannelExist('chat')).toBe(true)
5555
```
5656

5757
## Get mock channel object
@@ -66,7 +66,7 @@ Mock channel object has functions `eventExist`, `broadcast`, etc.
6666

6767
Example:
6868
```javascript
69-
expect(mockEcho.getChannel('news').eventExist('NewsMessage')).toBe(true)
69+
expect(mockEcho.getChannel('news').eventExist('NewsMessage')).toBe(true)
7070
```
7171

7272
## Determine whether event has been listened
@@ -79,9 +79,9 @@ You can use `getChannel(channelName).eventExist`, `getPrivateChannel(channelName
7979

8080
Example:
8181
```javascript
82-
expect(mockEcho.getChannel('news').eventExist('NewsMessage')).toBe(true)
83-
expect(mockEcho.getPrivateChannel('meeting').eventExist('MeetingMessage')).toBe(true)
84-
expect(mockEcho.getPresenceChannel('chat').eventExist('ChatMessage')).toBe(true)
82+
expect(mockEcho.getChannel('news').eventExist('NewsMessage')).toBe(true)
83+
expect(mockEcho.getPrivateChannel('meeting').eventExist('MeetingMessage')).toBe(true)
84+
expect(mockEcho.getPresenceChannel('chat').eventExist('ChatMessage')).toBe(true)
8585
```
8686

8787
## Broadcast event
@@ -92,11 +92,11 @@ You can use `broadcast` to broadcast an event.
9292
9393
Example:
9494
```javascript
95-
mockEcho.getChannel('news').broadcast('NewsMessage', { message: 'Hello World' })
96-
wrapper.vm.$nextTick(() => {
97-
expect(wrapper.find('.message').text()).toBe('It said Hello World')
98-
done()
99-
})
95+
mockEcho.getChannel('news').broadcast('NewsMessage', { message: 'Hello World' })
96+
wrapper.vm.$nextTick(() => {
97+
expect(wrapper.find('.message').text()).toBe('It said Hello World')
98+
done()
99+
})
100100
```
101101

102102
## Presence channel actions
@@ -111,24 +111,24 @@ You can use `iJoin`, `userJoin`, `userLeave` to trigger presence channel actions
111111
112112
Example:
113113
```javascript
114-
mockEcho.getPresenceChannel('chat').iJoin({id: 1, name: 'Alex'})
115-
wrapper.vm.$nextTick(() => {
116-
expect(wrapper.find('.here-message').text()).toBe('There are 1 users')
117-
done()
118-
})
119-
120-
// You will need paulSubId to get this user away from this channel
121-
let paulSubId = mockEcho.getPresenceChannel('chat').userJoin({id: 2, name: 'Paul'})
122-
wrapper.vm.$nextTick(() => {
123-
expect(wrapper.find('.join-message').text()).toBe('Paul joined')
124-
done()
125-
})
126-
127-
mockEcho.getPresenceChannel('chat').userLeave(paulSubId)
128-
wrapper.vm.$nextTick(() => {
129-
expect(wrapper.find('.leave-message').text()).toBe('Paul leaved')
130-
done()
131-
})
114+
mockEcho.getPresenceChannel('chat').iJoin({id: 1, name: 'Alex'})
115+
wrapper.vm.$nextTick(() => {
116+
expect(wrapper.find('.here-message').text()).toBe('There are 1 users')
117+
done()
118+
})
119+
120+
// You will need paulSubId to get this user away from this channel
121+
let paulSubId = mockEcho.getPresenceChannel('chat').userJoin({id: 2, name: 'Paul'})
122+
wrapper.vm.$nextTick(() => {
123+
expect(wrapper.find('.join-message').text()).toBe('Paul joined')
124+
done()
125+
})
126+
127+
mockEcho.getPresenceChannel('chat').userLeave(paulSubId)
128+
wrapper.vm.$nextTick(() => {
129+
expect(wrapper.find('.leave-message').text()).toBe('Paul leaved')
130+
done()
131+
})
132132
```
133133

134134
## Client events
@@ -139,19 +139,19 @@ You can use `userWhisper` to send user event. Only private channel object and pr
139139
140140
Example:
141141
```javascript
142-
// private channel
143-
mockEcho.getPrivateChannel('meeting').userWhisper('meetingClicking', { username: username })
144-
wrapper.vm.$nextTick(() => {
145-
expect(wrapper.find('.whisper-message').text()).toBe(`${username} is clicking the button`)
146-
done()
147-
})
148-
149-
// presence channel
150-
mockEcho.getPresenceChannel('chat').userWhisper('chatClicking', { username: username })
151-
wrapper.vm.$nextTick(() => {
152-
expect(wrapper.find('.whisper-message').text()).toBe(`${username} is clicking the button`)
153-
done()
154-
})
142+
// private channel
143+
mockEcho.getPrivateChannel('meeting').userWhisper('meetingClicking', { username: username })
144+
wrapper.vm.$nextTick(() => {
145+
expect(wrapper.find('.whisper-message').text()).toBe(`${username} is clicking the button`)
146+
done()
147+
})
148+
149+
// presence channel
150+
mockEcho.getPresenceChannel('chat').userWhisper('chatClicking', { username: username })
151+
wrapper.vm.$nextTick(() => {
152+
expect(wrapper.find('.whisper-message').text()).toBe(`${username} is clicking the button`)
153+
done()
154+
})
155155
```
156156

157157
# If you found any bugs

0 commit comments

Comments
 (0)