1 00:00:01,110 --> 00:00:02,520 Our Senate function is complete. 2 00:00:02,530 --> 00:00:05,910 We're now going to start to roll out some tests around our order created listener. 3 00:00:06,230 --> 00:00:08,000 So we'll throw down a first test right here. 4 00:00:08,050 --> 00:00:09,730 What do we really care about testing here. 5 00:00:09,730 --> 00:00:16,150 Well we probably really want to make sure that we take the ticket and we set its I.D. or the order I.D. 6 00:00:16,160 --> 00:00:20,380 property equal to whatever the order I.D. was out of the data object. 7 00:00:20,380 --> 00:00:21,220 That's the big goal here. 8 00:00:21,220 --> 00:00:23,330 That's what we are really trying to do. 9 00:00:23,350 --> 00:00:28,000 We also of course care about acting the message as well assuming everything goes as expected. 10 00:00:28,850 --> 00:00:33,060 So we're going to write out to success case tests once again we'll say it. 11 00:00:33,220 --> 00:00:36,220 That's the user I.D. of the ticket 12 00:00:39,480 --> 00:00:47,450 we'll do one test for that and then another test to say that it calls the EQ message. 13 00:00:47,480 --> 00:00:56,820 But I think in our previous test we just simply said acts the message just be a little bit more concise. 14 00:00:56,910 --> 00:00:59,610 So in our first test right here we'll call our setup function. 15 00:00:59,610 --> 00:01:04,300 It is an async function we'll just make sure that we use the awake key word on it. 16 00:01:04,420 --> 00:01:13,500 We'll out the listener ticket data and message from a weight setup looks good so we're then going to 17 00:01:13,500 --> 00:01:21,690 take our listeners on message function and call it with the data and message arguments so a listener 18 00:01:22,200 --> 00:01:27,490 on message Pass and data and message that we can write out our expectation. 19 00:01:27,490 --> 00:01:32,790 So in this case we want to reach into our database once again we want to find that ticket that has presumably 20 00:01:32,790 --> 00:01:38,610 been updated inside there and then just make sure that the ticket has its user or me order I.D. property 21 00:01:38,610 --> 00:01:39,590 set. 22 00:01:39,800 --> 00:01:44,180 Now the ticket that we already have inside of here that is an out of date ticket document presumably 23 00:01:44,180 --> 00:01:48,620 we have already written an updated version back into our data collection or the collection of all of 24 00:01:48,620 --> 00:01:49,360 our different tickets. 25 00:01:49,370 --> 00:01:57,460 So we do have to refashion the thing we'll say updated ticket is a weight ticket find by I.D. We want 26 00:01:57,460 --> 00:02:01,000 to find a ticket with the same I.D. as the one we have right here. 27 00:02:01,000 --> 00:02:06,820 But again we have to repair this thing because it has some out-of-date data so then take a look at the 28 00:02:06,820 --> 00:02:15,060 updated ticket and just make sure that it's ordered property asset that's it they'll do and expect updated 29 00:02:15,270 --> 00:02:28,360 ticket exclamation dot order I.D. to equal the data objects I.D. data dot I.D. and again data I.D. is 30 00:02:28,360 --> 00:02:34,290 the idea of the order that we had just created and that should be at let's say this will go back over 31 00:02:34,290 --> 00:02:40,390 to our terminal and start up our test suite inside of our tickets service. 32 00:02:40,560 --> 00:02:44,250 I still had the test going for my order service right here I'm going to close all that stuff down because 33 00:02:44,250 --> 00:02:47,200 really focused on the ticket service right now. 34 00:02:47,340 --> 00:02:51,390 I'll go back over two tickets to an NPM run test and we'll see how we're doing. 35 00:02:51,390 --> 00:02:55,800 Now we might see some other failures inside of here or all those going to same versioning issues around 36 00:02:55,800 --> 00:02:56,570 our root handlers. 37 00:02:56,580 --> 00:02:59,090 We saw a little bit ago so some other stuff is failing. 38 00:02:59,100 --> 00:02:59,840 That's OK. 39 00:02:59,850 --> 00:03:02,540 Looks like we're okay In this case however don't Alex. 40 00:03:02,550 --> 00:03:09,270 Fantastic and I just want to find my listener test right there in particular Let's filter our tests 41 00:03:09,270 --> 00:03:15,320 and just run the listener 1 I'll do a P and then listener 42 00:03:18,980 --> 00:03:23,660 and we'll make sure that that thing fails as usual I know the step seems kind of arbitrary and not important 43 00:03:23,690 --> 00:03:28,310 but you would be surprised how often you can actually capture a little mistakes in your testing by making 44 00:03:28,310 --> 00:03:30,290 sure that stuff actually does fail. 45 00:03:30,320 --> 00:03:35,510 So I will comment that thing out now we should not be sending to use the order I.D. property at all. 46 00:03:35,510 --> 00:03:37,820 And we do in fact this thing fail. 47 00:03:37,920 --> 00:03:39,130 No that's fantastic. 48 00:03:40,660 --> 00:03:42,170 Get back to working. 49 00:03:42,170 --> 00:03:47,000 Let's now also take care of making sure that we act the message as well. 50 00:03:47,040 --> 00:03:50,580 We're going to again do the setup step those copy paste that down. 51 00:03:50,580 --> 00:03:52,200 We're gonna call on message once again. 52 00:03:52,200 --> 00:03:57,900 Copy paste that down and then we can take a look at the message dot at property and just make sure it 53 00:03:57,900 --> 00:04:07,440 was invoked so expect message Scott back to have been dealt so I can save that passes comment out on 54 00:04:07,440 --> 00:04:10,250 message save it fails. 55 00:04:10,310 --> 00:04:16,720 Everything is good to go well all right well I'd say that our order created listener looks pretty reasonable 56 00:04:17,230 --> 00:04:20,050 but there might be one or two other things we want to take care of inside of here. 57 00:04:20,120 --> 00:04:25,420 So take a quick pause kind of walk through this entire workflow of resolving a ticket or reserving a 58 00:04:25,420 --> 00:04:28,240 ticket and some things we might want to do along that process.