This repository has been archived by the owner on Nov 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: emit list-users on user update
- Loading branch information
Showing
7 changed files
with
109 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export class EventToClient { | ||
// static readonly RoomGuestsList = 'room-guests-list' | ||
|
||
// static readonly UsersList = 'users-list' | ||
static readonly UsersList = 'users-list' | ||
|
||
static readonly InternalServerError = 'internal-server-error' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// export * from "./room.guests.list.event"; | ||
|
||
// export * from "./users.list.event"; | ||
export * from './users.list.event' | ||
|
||
export * from './internal.server.error.event' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { expect } from 'chai' | ||
import { UsersListEvent } from './users.list.event' | ||
import { ExportedUser } from '../../index' | ||
|
||
describe('Events', () => { | ||
describe('UsersListEvent', () => { | ||
it("should have 'users-list' event as name", () => { | ||
expect(UsersListEvent.eventName).to.equal('users-list') | ||
}) | ||
|
||
it('should initialize exportedUsers object', () => { | ||
// arrange | ||
const exportedUsers: ExportedUser[] = [ | ||
{ name: 'Usain', color: '#FFFF00' }, | ||
{ name: 'Bob', color: '#333' }, | ||
] | ||
|
||
// act | ||
let usersList = new UsersListEvent(exportedUsers) | ||
|
||
// assert | ||
expect(usersList.exportedUsers).to.not.be.undefined | ||
expect(usersList.exportedUsers).to.have.length(2) | ||
expect(usersList.exportedUsers).to.equal(exportedUsers) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { EventToClient } from './event.to.client' | ||
import { ExportedUser } from '../../index' | ||
|
||
export class UsersListEvent { | ||
static eventName: string = EventToClient.UsersList | ||
// TODO: send less information to the client? | ||
constructor(public readonly exportedUsers: ExportedUser[]) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters