-
Notifications
You must be signed in to change notification settings - Fork 16
Lab-Dana #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dkulp23
wants to merge
11
commits into
codefellows-javascript-401d13:master
Choose a base branch
from
dkulp23:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Lab-Dana #9
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
edf26b6
Creating file structure
dkulp23 261c4c0
Wrote simple script in lib directory for testing.
dkulp23 6fc6ea5
Wrote entry point script in index.js
dkulp23 dbcce0a
Simple script passed testing. Working on process.argv to accept input…
dkulp23 17a9fa2
Input is logging to console.
dkulp23 535291b
Updated test to include reference to command line argument input.
dkulp23 37c7611
Testing out process.argv properties to determine how to handle multip…
dkulp23 f82092b
I feel like I learned a fair amount about the argv property of the pr…
dkulp23 55e2db7
One test written for each method. Passing both.
dkulp23 bbe1e65
Not quite satisfied with the way I'm formatting the string output but…
dkulp23 0f7d757
Added test for empty input.
dkulp23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
const welcome = require('./lib/howdy.js'); | ||
|
||
if (process.argv.length < 3) throw new Error('please enter a name!'); | ||
|
||
if (process.argv.length === 3) welcome.greeting(process.argv[2]); | ||
|
||
if (process.argv.length > 3) welcome.multipleGreetings(process.argv); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
module.exports = exports = {}; | ||
|
||
exports.greeting = function(name) { | ||
if (arguments.length === 0) throw new Error('no name given'); | ||
console.log(`What's up, ${name}?!`); | ||
return `hello ${name}`; | ||
}; | ||
|
||
exports.multipleGreetings = function(termInput) { | ||
let names = termInput.slice(2); | ||
let logMessage = " "; | ||
logMessage += names.slice(0, -1).join(', '); | ||
logMessage += (' and '); | ||
logMessage += names.slice(-1).join(''); | ||
logMessage += ('!'); | ||
console.log(`Hey there ${logMessage}`); | ||
return `Hey there ${logMessage}`; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const howdy = require('../lib/howdy.js'); | ||
// const hackyMessageVariable = howdy.multipleGreetings.logMessage; | ||
// console.log(hackyMessageVariable); | ||
|
||
describe('Howdy Module', function() { | ||
describe('#greeting', function() { | ||
it(`should return hello ${process.argv[2]}`, function() { | ||
let printout = howdy.greeting(process.argv[2]); | ||
assert.ok(printout === `hello ${process.argv[2]}`, 'incorrect result'); | ||
}); | ||
}); | ||
describe('#greeting', function() { | ||
it('Should result in error from missing input', function() { | ||
assert.throws(function() { | ||
howdy.greeting(); | ||
}, 'Error not thrown for empty input'); | ||
}); | ||
}); | ||
describe('#multipleGreetings', function() { | ||
it(`should return all names entered in command line`, function() { | ||
let printout = howdy.multipleGreetings(process.argv); | ||
assert.ok(printout === `Hey there ${hackyMessageVariable}`, 'not quite right'); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great variable name. :)