added test for bad TLD, better named 404 url test

pull/22/head
Adam Townsend 2023-10-12 19:02:38 -07:00
parent 7eaa8eacf8
commit bbb710a5e1
1 changed files with 11 additions and 1 deletions

View File

@ -66,7 +66,7 @@ describe "Submit API request to create new link" do
expect(response_json['message']).to eq('invalid url parameter')
end
it "should return with a 400 status and 'url not found' message when an invalid url is submitted" do
it "should return with a 400 status and 'url not found' message when a 404 url is submitted" do
data = {
url: 'http://google.com/example'
}
@ -75,4 +75,14 @@ describe "Submit API request to create new link" do
response_json = JSON.parse(last_response.body)
expect(response_json['message']).to eq('url not found')
end
it "should return with a 400 status and 'url not found' message when a URL with no DNS is submitted" do
data = {
url: 'http://bad.tld'
}
post('/links', data.to_json, "CONTENT_TYPE" => "application/json")
expect(last_response.status).to eq(400)
response_json = JSON.parse(last_response.body)
expect(response_json['message']).to eq('url does not resolve')
end
end