So let's just write out an example here.
I'm just going to write out an example of what data we're actually trying to get.
So we want an array of these listings.
We have an array here containing objects that have properties of the data.
So we have a title, for example, it could have a title of.
All the term time, all the time.
And bluegrass fiddle lessons.
That's the title here.
So we have that.
And then there's a URL, which is the URL you have when you click on the link here.
It's this one.
And then a date.
It was posted.
That could be a JavaScript date object.
So something like 2009, uh, something like this.
And then we have.
What else did we have?
We have the neighborhood.
So if I sample San Francisco, we have their.
So those are the different data points that we want from all the different listings.
And we're basically going to get an array of all these objects.
So now we want to actually kind of wrote the test sort of already.
So we say that, um, it should give the.
Correct.
Listing object.
So we say here, you should return this object here.
From parser.
So we say const results or const listings from parser dot listings and there we pass in some HTML that
we already defined up here in the in the before all, that's where we read the HTML file and define
the variable.
And then we pass in the we pass in the HTML text to parser dot listings where we parse it and get the
data.
So then we expect that well listings is the length of listings should be.
120 because there's 120 listings on this page.
And then we could also say that we expect.
Listings.
The first object of the title to be.
This title you have up here?
And then we can say we expect listings the first object to be or the URL.
To be.
This URL we have up here.
Let's paste that in.
And for good measures.
We actually want to have a test for each thing that you have.
I like to have a test for each thing so that you can very fast see what went wrong or what is missing.
That means we have a test for the title, a test for the URL, and maybe a test for the length as well.
So we could have a test here that says it.
Should get correct title.
And we say const listings.
Parser listings pass into HTML.
And then we say we expect listings zero the first listing to be this title.
And then I can easily see that.
Okay, this test with the title is failing so I can go and look at the code more efficiently this way.
Now, let's see.
Let's see.
We also need one for the URL.
It should get correct URL.
And in here, we just cut that.
And now instead of having this concert listings for every test, then we can simply use our before all
function again.
The one up here to define this listing variable.
So we can say let listings up here and say listings is equal to parser dot listings and we paste or
we pass in the HTML into the function here.
And then we have this array of listings and then we can test this listings array inside each function.
Then we don't have to write out const listings equals.
Uh, this call here for every function type or every test type we have.
So I can delete this one now because we have it defined in the global scope.
Now we have.
We also have to test for the neighborhood.
Should get Hood from listing.
So we say expect listings first one to be or not to be.
What should it be?
It should be San Francisco.
And then we also need to get the date.
So we say it should get correct date from listing.
And then we say we expect.
Listings.
Zero.
Date Posted.
To be.
And here we have to look at the Chrome developer tools and find out exactly what the date time is.
So I'm going to go into Chrome Developer Tools and I select an element and I click on the little date
we have here.
And I can see the exact date here inside the datetime attribute, and we just copy that.
So then I say I want it to be equal to a new JavaScript date of this date.
And then.
I think that should be it.
Um, okay.
So I'm going to delete this example.
That's just for showing you guys what kind of data we are trying to get or how it's going to look.
So I'm going to delete that now.
So now we have all of our test out here.
We have a one for the length.
It should give the correct.
Number of listings to be 120 should get the hood from the listing.
San Francisco.
It should get the correct date, which is the date posted.
And it should get the correct URL.
And it should get the correct title.
So those four things are what we are looking for in the data of each of the listings.
Now we should check out our test and we see we have.
Actually six failed tests.
Because the before all function is failing, because listings is not a function inside parser.
And actually, I think we should just remove this.
It should give four functions.
Let's go and remove that.
Because we are not going to be adding any numbers anymore inside this.