diff --git a/tests/Browser/NotesTest.php b/tests/Browser/NotesTest.php new file mode 100644 index 00000000..81a59b3f --- /dev/null +++ b/tests/Browser/NotesTest.php @@ -0,0 +1,35 @@ +browse(function ($browser) { + $browser->visit('/notes/D') + ->assertSee('JBL5'); + }); + } + + /** + * Look for the client URL after the note. + * + * @return void + */ + public function test_client_url_displayed() + { + $this->browse(function ($browser) { + $browser->visit('/notes/E') + ->assertSee('quill.p3k.io'); + }); + } +} diff --git a/tests/Feature/NotesControllerTest.php b/tests/Feature/NotesControllerTest.php new file mode 100644 index 00000000..df1518bb --- /dev/null +++ b/tests/Feature/NotesControllerTest.php @@ -0,0 +1,57 @@ +get('/notes'); + $response->assertStatus(200); + } + + /** + * Test a specific note. + * + * @return void + */ + public function test_specific_note() + { + $response = $this->get('/notes/D'); + $response->assertViewHas('note'); + } + + /** + * Test that `/note/{decID}` redirects to `/notes/{nb60id}`. + * + * @return void + */ + public function test_dec_id_redirect() + { + $response = $this->get('/note/11'); + $response->assertRedirect(config('app.url') . '/notes/B'); + } + + /** + * Visit the tagged page and check the tag view data. + * + * @return void + */ + public function test_tagged_notes_page() + { + $response = $this->get('/notes/tagged/beer'); + $response->assertViewHas('tag', 'beer'); + } +} diff --git a/tests/Unit/NotesControllerTest.php b/tests/Unit/NotesControllerTest.php new file mode 100644 index 00000000..2e654f5e --- /dev/null +++ b/tests/Unit/NotesControllerTest.php @@ -0,0 +1,71 @@ +notesController = new NotesController(); + } + + /** + * Test a correct profile link is formed from a generic URL. + * + * @return void + */ + public function test_create_photo_link_with_non_cached_image() + { + $notesController = new \App\Http\Controllers\NotesController(); + $homepage = 'https://example.org/profile.png'; + $expected = 'https://example.org/profile.png'; + $this->assertEquals($expected, $this->notesController->createPhotoLink($homepage)); + } + + /** + * Test a correct profile link is formed from a generic URL (cached). + * + * @return void + */ + public function test_create_photo_link_with_cached_image() + { + $notesController = new \App\Http\Controllers\NotesController(); + $homepage = 'https://aaronparecki.com/profile.png'; + $expected = '/assets/profile-images/aaronparecki.com/image'; + $this->assertEquals($expected, $this->notesController->createPhotoLink($homepage)); + } + + /** + * Test a correct profile link is formed from a twitter URL. + * + * @return void + */ + public function test_create_photo_link_with_twimg_profile_image_url() + { + $notesController = new \App\Http\Controllers\NotesController(); + $twitterProfileImage = 'http://pbs.twimg.com/1234'; + $expected = 'https://pbs.twimg.com/1234'; + $this->assertEquals($expected, $this->notesController->createPhotoLink($twitterProfileImage)); + } + + /** + * Test `null` is returned for a twitter profile. + * + * @return void + */ + public function test_create_photo_link_with_cached_twitter_url() + { + $twitterURL = 'https://twitter.com/example'; + $expected = 'https://pbs.twimg.com/static_profile_link.jpg'; + Cache::put($twitterURL, $expected, 1); + $this->assertEquals($expected, $this->notesController->createPhotoLink($twitterURL)); + } +} diff --git a/tests/Unit/NotesTest.php b/tests/Unit/NotesTest.php new file mode 100644 index 00000000..eef40e72 --- /dev/null +++ b/tests/Unit/NotesTest.php @@ -0,0 +1,70 @@ +Having a #beer at the local. 🍺
' . PHP_EOL; + $note = Note::find(11); + $this->assertEquals($expected, $note->note); + } + + /** + * Look for a default image in the contact’s h-card for the makeHCards method. + * + * @return void + */ + public function test_default_image_used_in_makehcards_method() + { + $expected = 'Hi
+
+
+ Tantek Çelik
+
+
Hi
+
+
+ Aaron Parecki
+
+
Hi @bob
' . PHP_EOL; + $note = Note::find(14); + $this->assertEquals($expected, $note->note); + } +}