Created
September 5, 2022 16:21
-
-
Save christophrumpel/f0f1ed5bf63a9160bbb98cea8eab54bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('returns readable video duration', function () { | |
// Arrange | |
$video = Video::factory()->create(['duration_in_min' => 10]); | |
// Act & Assert | |
expect($video->getReadableDuration())->toEqual('10min'); | |
}); | |
it('belongs to a course', function () { | |
// Arrange | |
$video = Video::factory()->has(Course::factory())->create(); | |
// Act & Assert | |
expect($video->course)->toBeInstanceOf(Course::class); | |
}); | |
it('shows course details', function () { | |
// Arrange | |
$course = Course::factory() | |
->has(Video::factory()) | |
->released() | |
->create(); | |
// Act & Assert | |
get(route('page.course-details', $course)) | |
->assertOk() | |
->assertSeeText([ | |
$course->title, | |
$course->tagline, | |
$course->description, | |
...$course->learnings, | |
]) | |
->assertSee($course->image_name); | |
}); | |
it('shows course video count', function () { | |
// Arrange | |
$course = Course::factory() | |
->has(Video::factory()->count(3)) | |
->released() | |
->create(); | |
// Act & Assert | |
get(route('page.course-details', $course)) | |
->assertOk() | |
->assertSeeText('3 videos'); | |
}); | |
it('shows details from given video', function () { | |
// Arrange | |
$course = createCourseAndVideos(); | |
$video = $course->videos()->first(); | |
// Act & Assert | |
Livewire::test(VideoPlayer::class, ['video' => $video]) | |
->assertSeeText([ | |
$video->title, | |
$video->description, | |
"({$video->duration_in_min}min)", | |
]); | |
}); | |
it('includes link to course videos', function () { | |
// Arrange | |
$user = User::factory() | |
->has(Course::factory()->has(Video::factory()), 'purchasedCourses') | |
->create(); | |
// Act | |
loginAsUser($user); | |
get(route('page.dashboard')) | |
->assertOk() | |
->assertSeeText('Watch videos') | |
->assertSee(route('page.videos', Course::first())); | |
}); | |
it('includes logout route', function () { | |
// Act & Assert | |
loginAsUser(); | |
get(route('page.dashboard')) | |
->assertOk() | |
->assertSeeText('Log Out') | |
->assertSee(route('logout')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment