Instructor: In the last section,
we created our app test file
and now we're gonna work
on the actual implementation of this test.
So the first thing we need to know what to do
is what to actually write inside the file.
To give you a better idea of what's going on,
let's check out a quick diagram.
Okay, so this right here is a diagram
of the main construct that we're going to use again,
and again, and again, throughout this testing suite.
Inside this diagram, I've labeled out a function
that we're going to be calling over and over,
every single time that we want to write out a new test.
So we refer to this function as the IT function.
I personally sometimes call it an IT block.
Now you're gonna find very few other people
who call this function the IT block.
I call that personally
because back when I was writing Ruby Code and Ruby on Rails,
we referred to kind of that testing setup.
We called it the IT block over there.
So you're not gonna find a lot of other people
in the JavaScript world that refer to this as the IT block
but sometimes out of habit, that's what I'm gonna call it.
The IT function is a global function.
That means that you and I do not have to require it
or import it into our test file.
We can just freely call the IT function
and we're good to go.
The IT function is used to organize
all the different tests
that we write inside of a single file.
So for each test we write,
we will call the IT function exactly one time.
The arguments to the IT function
are always going to be the same.
The first argument is gonna be a string
that is a description of the test
that you and I are going to write.
So this is going to be a string description
solely meant to communicate the purpose of the test
to ourselves in the future
or other developers in the future.
This string right here is not used by the testing suite
for any behind the scenes testing purpose.
All it's there for is for communicating the intent
of the test to yourself and other engineers.
As a second argument to the IT function,
we're gonna pass in a function that you and I create.
And this function is gonna contain the actual body
or the actual test logic that we want to execute.
It's gonna contain the code that actually runs
whatever we say this thing is going to run
or whatever it's actually going to test.
So let's flip back over to our app test file
and write out our first IT block or our first IT function.
So back over here inside my app test file.
I'll write out it, and then as a first argument
I'll provide a string.
So again, this is string right here
is going to be a description of what we're trying to test.
So as a quick reminder, what we're trying to test right now
around our app component, is to just make sure
that it shows our comment box.
That's gonna be the first test we write.
So as a description for this, on the very first test
I'm gonna say, shows a comment box.
Now I want you to take a quick look
at the string right here.
You'll notice that I didn't write out something like
'The App' or anything like that.
I didn't write out, it shows the comment box.
Whenever we write a description in here,
we want to kind of imagine
that the IT function right here kind of blends
into the name or the description that we're providing.
And so I would read this test right here
as it shows a comment box.
When we start thinking about what it is,
well the it is implied to me whatever we named this file.
So in this case we named the file app dot test dot js.
So in total, I would read this statement right here
as saying the app component,
hey, let me tell you about it.
It shows a comment box.
And then as a second argument,
we'll provide a function that shows that is the case
and actually kind of proves that
it shows a comment box with some amount of code.
So let's place that second argument here.
It's gonna be a function like so.
And then inside this function
is where we're going to implement our actual test logic.
So let's take a quick pause,
we'll come back to the next section
and start implementing the test.