Now let's go ahead and add one thing to our test file. In order to get these methods to work, we're going to need seed data, we're going to need users that already exist otherwise we can't remove one or get one, and we definitely can't get a list of the rooms these non-existent users are in.
In order to fix that over inside user.test.js, we're going to add a beforeEach call, which we've used in the past. The beforeEach call, as we know, is going to get called before every single test case. It's going to help us initialize some data. Now the data we're going to initialize is going to be defined just above the beforeEach call, in a variable called users:
describe('Users', () => {
var users;
beforeEach(() => {
});
The reason I'm defining it outside of beforeEach is so it's accessible inside of beforeEach and it's accessible inside of the test cases, we have defined down below.
Inside of beforeEach we're going to set users equal to new Users, and we're also going to set the users.users array. Here we can specify an array of objects, and this is going to let us add some initializing data:
beforeEach(() => {
users = new Users();
users.users = [{
}]
});
Let's go ahead and provide three objects. The first one will have an id property equal to 2, we'll set the name property equal to something like Mike, and we can go ahead and set the room property equal to whatever we like, I'm going to go ahead and use a room name of Node Course:
var users;
beforeEach(() => {
users = new Users();
users.users = [{
id: '1',
name: 'Mike',
room: 'Node Course'
}]
});
We can take this object and copy it two more times. I'm going to add a comma, paste in what I just copied and do the same thing again, comma followed by a paste. I'm going to change it to an id of 2 for the second user, we'll change the name to something like Jen and we'll change the room name to React Course. Now for the last user, we are going to change id and name, we'll make id equals 3, and we'll make the name something like Julie, but we're going to leave the room as Node Course so we can test that our getUserList function does indeed return the correct results:
beforeEach(() => {
users = new Users();
users.users = [{
id: '1',
name: 'Mike',
room: 'Node Course'
},{
id: '2',
name: 'Jen',
room: 'React Course'
},{
id: '3',
name: 'Julie',
room: 'Node Course'
}]
});
The test cases aren't going to be required to use our users variable as defined here. We can still define a custom one as we defined in case of adding new user. If I run the test-watch script, npm run test-watch, we're going to see that our one test case is still passing:

I'm going to save the file to rerun the test suite, and right here we have 6 passing test cases. Regardless of whether or not we use this, we can still use a custom test case.
Now that we have this in place, we can go ahead and start filling out some of these methods. We're going to fill out getUserList together, and you're going to be responsible for removeUser and getUser.