Our Senate function is complete.
We're now going to start to roll out some tests around our order created listener.
So we'll throw down a first test right here.
What do we really care about testing here.
Well we probably really want to make sure that we take the ticket and we set its I.D. or the order I.D.
property equal to whatever the order I.D. was out of the data object.
That's the big goal here.
That's what we are really trying to do.
We also of course care about acting the message as well assuming everything goes as expected.
So we're going to write out to success case tests once again we'll say it.
That's the user I.D. of the ticket
we'll do one test for that and then another test to say that it calls the EQ message.
But I think in our previous test we just simply said acts the message just be a little bit more concise.
So in our first test right here we'll call our setup function.
It is an async function we'll just make sure that we use the awake key word on it.
We'll out the listener ticket data and message from a weight setup looks good so we're then going to
take our listeners on message function and call it with the data and message arguments so a listener
on message Pass and data and message that we can write out our expectation.
So in this case we want to reach into our database once again we want to find that ticket that has presumably
been updated inside there and then just make sure that the ticket has its user or me order I.D. property
set.
Now the ticket that we already have inside of here that is an out of date ticket document presumably
we have already written an updated version back into our data collection or the collection of all of
our different tickets.
So we do have to refashion the thing we'll say updated ticket is a weight ticket find by I.D. We want
to find a ticket with the same I.D. as the one we have right here.
But again we have to repair this thing because it has some out-of-date data so then take a look at the
updated ticket and just make sure that it's ordered property asset that's it they'll do and expect updated
ticket exclamation dot order I.D. to equal the data objects I.D. data dot I.D. and again data I.D. is
the idea of the order that we had just created and that should be at let's say this will go back over
to our terminal and start up our test suite inside of our tickets service.
I still had the test going for my order service right here I'm going to close all that stuff down because
really focused on the ticket service right now.
I'll go back over two tickets to an NPM run test and we'll see how we're doing.
Now we might see some other failures inside of here or all those going to same versioning issues around
our root handlers.
We saw a little bit ago so some other stuff is failing.
That's OK.
Looks like we're okay In this case however don't Alex.
Fantastic and I just want to find my listener test right there in particular Let's filter our tests
and just run the listener 1 I'll do a P and then listener
and we'll make sure that that thing fails as usual I know the step seems kind of arbitrary and not important
but you would be surprised how often you can actually capture a little mistakes in your testing by making
sure that stuff actually does fail.
So I will comment that thing out now we should not be sending to use the order I.D. property at all.
And we do in fact this thing fail.
No that's fantastic.
Get back to working.
Let's now also take care of making sure that we act the message as well.
We're going to again do the setup step those copy paste that down.
We're gonna call on message once again.
Copy paste that down and then we can take a look at the message dot at property and just make sure it
was invoked so expect message Scott back to have been dealt so I can save that passes comment out on
message save it fails.
Everything is good to go well all right well I'd say that our order created listener looks pretty reasonable
but there might be one or two other things we want to take care of inside of here.
So take a quick pause kind of walk through this entire workflow of resolving a ticket or reserving a
ticket and some things we might want to do along that process.