Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions app/assets/javascripts/app/utils/ms-formatter.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
function pluralize(word, count) {
return `${word}${count !== 1 ? 's' : ''}`;
}

function formatMinutes(minutes) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be simplified to return minutes || 0;?

if (!minutes) return 0;

return `${minutes} ${pluralize('minute', minutes)}`;
return minutes || 0;
}

function formatSeconds(seconds) {
return `${seconds} ${pluralize('second', seconds)}`;
return seconds < 10 ? `0{seconds}` : seconds;
}

export default (milliseconds) => {
Expand All @@ -20,5 +14,5 @@ export default (milliseconds) => {
const displayMinutes = formatMinutes(minutes);
const displaySeconds = formatSeconds(remainingSeconds);

return `${displayMinutes} and ${displaySeconds}`;
return `${displayMinutes}:${displaySeconds}`;
};
4 changes: 2 additions & 2 deletions spec/features/users/sign_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
ajax_headers = { 'name' => 'X-Requested-With', 'value' => 'XMLHttpRequest' }

expect(request_headers).to include ajax_headers
expect(page).to have_content('7 minutes and 59 seconds')
expect(page).to have_content('7 minutes and 58 seconds')
expect(page).to have_content('7:59')
expect(page).to have_content('7:58')
end

scenario 'user can continue browsing' do
Expand Down