-
Notifications
You must be signed in to change notification settings - Fork 14
Kaylyn Lab 01 #12
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
base: master
Are you sure you want to change the base?
Kaylyn Lab 01 #12
Changes from all commits
422a0e1
e7c2d32
4fd1bc6
5f45ea1
085e251
5ddff12
547ddc4
56ca1c3
b71a989
9156cee
35fa25c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| 'use strict'; | ||
|
|
||
| module.exports = function greet(name) { | ||
| if (!name) throw new Error('expected name'); | ||
| return 'hello ' + name; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kaylynyuh try using string interpolation, it's super efficient and makes things cleaner and more dynamic. For example: you have: when you can also do: |
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "name": "lab-01-modular-patterns", | ||
| "version": "1.0.0", | ||
| "description": " Lab 01: Modular Patterns and Testing ===", | ||
| "main": "index.js", | ||
| "directories": { | ||
| "test": "test" | ||
| }, | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/kaylynyuh/lab-01-modular-patterns.git" | ||
| }, | ||
| "author": "yuhkay4@gmail.com", | ||
| "license": "MIT", | ||
| "bugs": { | ||
| "url": "https://github.com/kaylynyuh/lab-01-modular-patterns/issues" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kaylynyuh awesome use of the bugs property to add in your github issues link! |
||
| }, | ||
| "homepage": "https://github.com/kaylynyuh/lab-01-modular-patterns#readme", | ||
| "devDependencies": { | ||
| "eslint": "^3.5.0", | ||
| "gulp": "^3.9.1", | ||
| "gulp-eslint": "^3.0.1", | ||
| "gulp-mocha": "^3.0.1", | ||
| "mocha": "^3.0.2" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| 'use strict'; | ||
|
|
||
| const greet = require('../lib/greet.js'); | ||
| const assert = require('assert'); | ||
|
|
||
| describe('testing greet module', function() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kaylynyuh best practice is to include an additional describe block, inside of this one, that includes the method name - your outer describe block should reference the module that you are testing. For example: |
||
| it('should say hello world', function() { | ||
| assert.equal(greet('world'), 'hello world'); | ||
| }); | ||
| it('should throw missing name error', function() { | ||
| assert.throws(function (){ | ||
| greet(); | ||
| }, 'error thrown'); | ||
| }); | ||
| }); | ||
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.
@kaylynyuh AWESOME attribution provided here - keep that up!