From aca2d35d062164fb0414997862d40a85812bcf2a Mon Sep 17 00:00:00 2001 From: J2EEbbesen Date: Tue, 8 Oct 2024 19:28:22 -0500 Subject: [PATCH] Coverage (#90) * git ignoring coverage output * refactoring embedded script --- .gitignore | 1 + public/js/script.js | 11 ++++------- src/script.js | 11 ++++------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 6895bf0..30c78ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules coverage +mochawesome-report diff --git a/public/js/script.js b/public/js/script.js index 21fd0e3..36d253b 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -29,10 +29,6 @@ export function formatGeoInfo(loc) { return str; } -export function showLocations(html) { - document.querySelector('#results').innerHTML = html; -} - export function locationError(err) { console.log('Error getting location', err); let message = ` @@ -47,7 +43,7 @@ export function locationError(err) { return `${message}`; } -export function populateResults(c) { +export function populateResults() { navigator.geolocation.getCurrentPosition( function (location) { const xhr = new XMLHttpRequest(); @@ -55,7 +51,7 @@ export function populateResults(c) { const json = JSON.parse(xhr.response); const html = formatResults(json); - return showLocations(html); + return (document.querySelector('#results').innerHTML = html); }; xhr.open( 'GET', @@ -68,7 +64,8 @@ export function populateResults(c) { xhr.send(); }, function (err) { - return showLocations(locationError(err)); + return (document.querySelector('#results').innerHTML = + locationError(err)); }, ); } diff --git a/src/script.js b/src/script.js index 21fd0e3..36d253b 100644 --- a/src/script.js +++ b/src/script.js @@ -29,10 +29,6 @@ export function formatGeoInfo(loc) { return str; } -export function showLocations(html) { - document.querySelector('#results').innerHTML = html; -} - export function locationError(err) { console.log('Error getting location', err); let message = ` @@ -47,7 +43,7 @@ export function locationError(err) { return `${message}`; } -export function populateResults(c) { +export function populateResults() { navigator.geolocation.getCurrentPosition( function (location) { const xhr = new XMLHttpRequest(); @@ -55,7 +51,7 @@ export function populateResults(c) { const json = JSON.parse(xhr.response); const html = formatResults(json); - return showLocations(html); + return (document.querySelector('#results').innerHTML = html); }; xhr.open( 'GET', @@ -68,7 +64,8 @@ export function populateResults(c) { xhr.send(); }, function (err) { - return showLocations(locationError(err)); + return (document.querySelector('#results').innerHTML = + locationError(err)); }, ); }