diff --git a/README.md b/README.md index feae4effd..18b5968f4 100644 --- a/README.md +++ b/README.md @@ -9,45 +9,22 @@ Each exercise emphasizes the fundamentals of functional programming in JavaScrip 3. Run `npm install` 4. Test that the unit tests are working by running the command `npm test mythical-creatures/test/dragon-test.js` in your terminal -You should see something like: - -```shell -> foundations@1.0.0 test -> mocha mythical-creatures/test/dragon-test.js - - Dragon - - should be able to create a dragon with a name - - should be able to have a different name - - should have a rider - - should be able to have a different rider - - should have a temperment - - should be able to have different temperments - - should greet their rider - - should start off having eaten 0 times - - should start off being hungry - - should be full after eating 3 times - - should be a fireBreather if aggressive in temperment - - 0 passing (6ms) - 11 pending -``` -5. Make sure you read each subdirectory's README carefully before starting to code! - ## Overview -There are lots of test suites in this repo! Our recommendation is to work through this repo as preparation for your final assessment. - +There are lots of test suites in this repo! Our recommendation is to work through this repo as preparation for your final assessment. + We find that when students complete the same test suite over and over, memorization and pattern matching kick in (which is not what we want!). These test suites should be improving your problem solving skills. If you feel yourself being able to write code without reading the full test, itโ€™s probably time for a new test suite. You can (and should) be strategic about how you use these - for example, you might use one of the repos for a mock final assessment with your mentor. Completing all of these test suites is not necessary, but you should be working on this repo regularly. We see that students are the most successful when they establish a routine for working through these test suites. For example, you might work on them for 45 minutes every morning before class. Find a routine that works best for you and plan ahead so you remain on track to complete the majority of the tests. ### Test Suites -- [ ] ๐Ÿงš โ€[Mythical Creatures](./mythical-creatures) -- [ ] โœˆ๏ธ [Airport](./airport) -- [ ] ๐ŸŽง [DJ](./dj) -- [ ] ๐Ÿ” [Favorite Foods](./favorite-foods) + +- [x] ๐Ÿงš โ€[Mythical Creatures](./mythical-creatures) +- [x] โœˆ๏ธ [Airport](./airport) +- [x] ๐ŸŽง [DJ](./dj) +- [x] ๐Ÿ” [Favorite Foods](./favorite-foods) - [ ] ๐ŸŽฎ [Video Games](./video-games/) -- [ ] ๐ŸŽ‚ [Birthdays](./birthdays) +- [x] ๐ŸŽ‚ [Birthdays](./birthdays) - [ ] ๐Ÿ—“ [Calendar](./calendar/) - [ ] ๐Ÿ’ต [Vending Machine](./vending-machine/) - [ ] ๐Ÿ›— [Elevator](./elevator/) @@ -62,10 +39,8 @@ Completing all of these test suites is not necessary, but you should be working - [ ] ๐Ÿ“ผ [VHS](./vhs/) - [ ] ๐Ÿ‰ [RPG](./rpg/) -- [x] Want to track your progress? First, make sure you're on a forked version of this repo. Then, you can edit the README and change `[ ]` to `[x]` on the suites you've completed! - -## Skipped Tests +## TODO's -Most of the tests are skipped. When you see `it.skip('should be a function', function () {` in a test, it means that test has been skipped. They are skipped for a good reason - that way, when you run the test suite for the first time, you don't see tons of errors screaming at you in the terminal. +_Come back and finish later..._ -Unskip each test, one at a time in order, so you can concentrate on making one test pass. Unskip the test by deleting the `.skip` from the test's first line so it should look more like `it('should be a function', function () {`. Run the test to see what kind of error you are getting, and then implement the code to make the test pass! +- [ ] Mythical Creatures -> create custom creature & test suite diff --git a/airport/airport-test.js b/airport/airport-test.js index 5c1e20091..0fe335361 100644 --- a/airport/airport-test.js +++ b/airport/airport-test.js @@ -1,30 +1,57 @@ var assert = require('chai').assert; -var { createAirport, welcomeGuests, landPlanes, checkAirlineLocations } = require('./airport'); - -describe('Airport', function() { - it.skip('should create an airport', function() { - var airport = createAirport('Denver International Airport', ['United', 'Southwest', 'Delta'], 144); +var { + createAirport, + welcomeGuests, + landPlanes, + checkAirlineLocations, +} = require('./airport'); + +describe('Airport', function () { + it('should create an airport', function () { + var airport = createAirport( + 'Denver International Airport', + ['United', 'Southwest', 'Delta'], + 144 + ); assert.equal(airport.name, 'Denver International Airport'); assert.equal(airport.availableGates, 144); assert.equal(airport.airlines[0], 'United'); }); - it.skip('should welcome people to the airport', function() { - var denverAirport = createAirport('Denver International Airport', ['United', 'Southwest', 'Delta'], 144); - var sanDiegoAirport = createAirport('San Diego International Airport', ['Frontier', 'American'], 48); + it('should welcome people to the airport', function () { + var denverAirport = createAirport( + 'Denver International Airport', + ['United', 'Southwest', 'Delta'], + 144 + ); + var sanDiegoAirport = createAirport( + 'San Diego International Airport', + ['Frontier', 'American'], + 48 + ); - var denverWelcome = welcomeGuests(denverAirport); var sanDiegoWelcome = welcomeGuests(sanDiegoAirport); assert.equal(denverWelcome, 'Welcome to Denver International Airport!'); - assert.equal(sanDiegoWelcome, 'Welcome to San Diego International Airport!'); + assert.equal( + sanDiegoWelcome, + 'Welcome to San Diego International Airport!' + ); }); - it.skip('should keep track of open gates', function() { - var bakersfieldAirport = createAirport('Meadows Field Airport', ['United', 'American'], 12); - var sanDiegoAirport = createAirport('San Diego International Airport', ['Frontier', 'American'], 48); + it('should keep track of open gates', function () { + var bakersfieldAirport = createAirport( + 'Meadows Field Airport', + ['United', 'American'], + 12 + ); + var sanDiegoAirport = createAirport( + 'San Diego International Airport', + ['Frontier', 'American'], + 48 + ); var bakersfieldGates = landPlanes(bakersfieldAirport, 11); var sanDiegoGates = landPlanes(sanDiegoAirport, 2); @@ -33,33 +60,68 @@ describe('Airport', function() { assert.equal(sanDiegoGates.availableGates, 46); }); - it.skip('should not be able to occupy more gates than available', function() { - var columbusAiport = createAirport('John Glenn Airport', ['Southwest', 'Frontier'], 24); + it('should not be able to occupy more gates than available', function () { + var columbusAiport = createAirport( + 'John Glenn Airport', + ['Southwest', 'Frontier'], + 24 + ); var updatedAirportGates = landPlanes(columbusAiport, 22); assert.equal(updatedAirportGates.availableGates, 2); - assert.equal(updatedAirportGates.message, 'Success! Current availability is 2.') + assert.equal( + updatedAirportGates.message, + 'Success! Current availability is 2.' + ); var updatedAirportGates2 = landPlanes(updatedAirportGates, 3); assert.equal(updatedAirportGates2.availableGates, 0); - assert.equal(updatedAirportGates2.message, 'Oh no! Not enough gates available. Current overflow is 1.') + assert.equal( + updatedAirportGates2.message, + 'Oh no! Not enough gates available. Current overflow is 1.' + ); }); - it.skip('should be able to tell you where an airline flies to', function() { - var columbusAiport = createAirport('John Glenn Airport', ['Southwest', 'Frontier'], 24); - var bakersfieldAirport = createAirport('Meadows Field Airport', ['United', 'American'], 12); - var sanDiegoAirport = createAirport('San Diego International Airport', ['Frontier', 'American'], 48); - var denverAirport = createAirport('Denver International Airport', ['United', 'Southwest', 'Delta'], 144); - var allAirports = [columbusAiport, bakersfieldAirport, sanDiegoAirport, denverAirport]; + it('should be able to tell you where an airline flies to', function () { + var columbusAiport = createAirport( + 'John Glenn Airport', + ['Southwest', 'Frontier'], + 24 + ); + var bakersfieldAirport = createAirport( + 'Meadows Field Airport', + ['United', 'American'], + 12 + ); + var sanDiegoAirport = createAirport( + 'San Diego International Airport', + ['Frontier', 'American'], + 48 + ); + var denverAirport = createAirport( + 'Denver International Airport', + ['United', 'Southwest', 'Delta'], + 144 + ); + var allAirports = [ + columbusAiport, + bakersfieldAirport, + sanDiegoAirport, + denverAirport, + ]; var southwestCarriers = checkAirlineLocations(allAirports, 'Southwest'); var unitedCarriers = checkAirlineLocations(allAirports, 'United'); - assert.deepEqual(southwestCarriers, ['John Glenn Airport', 'Denver International Airport']); - assert.deepEqual(unitedCarriers, ['Meadows Field Airport', 'Denver International Airport']); + assert.deepEqual(southwestCarriers, [ + 'John Glenn Airport', + 'Denver International Airport', + ]); + assert.deepEqual(unitedCarriers, [ + 'Meadows Field Airport', + 'Denver International Airport', + ]); }); - - -}); \ No newline at end of file +}); diff --git a/airport/airport.js b/airport/airport.js index 8966a87f7..a5a0cafc9 100644 --- a/airport/airport.js +++ b/airport/airport.js @@ -1,9 +1,35 @@ +function createAirport(name, airlines, availableGates) { + return { name, airlines, availableGates }; +} +function welcomeGuests(airport) { + return `Welcome to ${airport.name}!`; +} +function landPlanes(airport, numberOfPlanes) { + airport.availableGates -= numberOfPlanes; + if (airport.availableGates < 0) { + airport.message = `Oh no! Not enough gates available. Current overflow is ${-airport.availableGates}.`; + airport.availableGates = 0; + } else { + airport.message = `Success! Current availability is ${airport.availableGates}.`; + } + return airport; +} -module.exports = { - // createAirport, - // welcomeGuests, - // landPlanes, - // checkAirlineLocations +function checkAirlineLocations(airports, carrier) { + const locations = []; + + for (const airport of airports) { + if (airport.airlines.includes(carrier)) locations.push(airport.name); + } + + return locations; +} + +module.exports = { + createAirport, + welcomeGuests, + landPlanes, + checkAirlineLocations, }; diff --git a/birthdays/birthdays-test.js b/birthdays/birthdays-test.js index a2573d210..4adb1d5ec 100644 --- a/birthdays/birthdays-test.js +++ b/birthdays/birthdays-test.js @@ -2,7 +2,7 @@ var assert = require('chai').assert; var { createBirthday, celebrateBirthday, countBirthdays } = require('./birthdays'); describe('Birthdays', function() { - it.skip('should create birthdays', function() { + it('should create birthdays', function() { var leahBirthday = createBirthday('Leah', 2, 10); var christyBirthday = createBirthday('Christy', 3, 8); @@ -15,7 +15,7 @@ describe('Birthdays', function() { assert.deepEqual(christyBirthday.day, 8); }); - it.skip('should celebrate birthdays', function() { + it('should celebrate birthdays', function() { var alexBirthday = createBirthday('Alex', 5, 19); var celebrateAlex = celebrateBirthday(alexBirthday); @@ -29,7 +29,7 @@ describe('Birthdays', function() { assert.equal(celebrateHeather, 'Today is 6/29! Happy birthday, Heather!'); }) - it.skip('should count how many birthdays are in a given month', function() { + it('should count how many birthdays are in a given month', function() { var leahBirthday = createBirthday('Leah', 2, 10); var christyBirthday = createBirthday('Christy', 3, 8); var alexBirthday = createBirthday('Alex', 5, 19); @@ -44,4 +44,4 @@ describe('Birthdays', function() { assert.equal(mayCount, 1); assert.equal(decCount, 0); }); -}); \ No newline at end of file +}); diff --git a/birthdays/birthdays.js b/birthdays/birthdays.js index 16d2dd549..66ef97a29 100644 --- a/birthdays/birthdays.js +++ b/birthdays/birthdays.js @@ -1,3 +1,27 @@ +function createBirthday(name, month, day) { + return { + name, + month, + day, + }; +} +function celebrateBirthday(birthday) { + return `Today is ${birthday.month}/${birthday.day}! Happy birthday, ${birthday.name}!` +} -module.exports = { }; \ No newline at end of file +function countBirthdays(birthdays, month) { + var count = 0; + + for (let i = 0; i < birthdays.length; i += 1) { + if (birthdays[i].month === month) count += 1; + } + + return count; +} + +module.exports = { + createBirthday, + celebrateBirthday, + countBirthdays, +}; diff --git a/dj/dj-test.js b/dj/dj-test.js index 78083bd78..57553667c 100644 --- a/dj/dj-test.js +++ b/dj/dj-test.js @@ -1,97 +1,139 @@ -var { createSong, playSong, makePlaylist, addSongToPlaylist, playSongs, playFavorites } = require('./dj'); +var { + createSong, + playSong, + makePlaylist, + addSongToPlaylist, + playSongs, + playFavorites, +} = require('./dj'); var assert = require('chai').assert; -describe('dj', function() { - it.skip('should be able to create songs', function() { - var song = createSong('Zombie Shuffle', 'The Creepy Crawlers', true) - - assert.equal(song.name, 'Zombie Shuffle'); - assert.equal(song.artist, 'The Creepy Crawlers'); - assert.equal(song.favorite, true); - }) - - it.skip('should not have been played by default', function() { - var song = createSong('Witches\' Brew Boogie', 'The Ghostly Ghouls', true) - - assert.equal(song.name, 'Witches\' Brew Boogie'); - assert.equal(song.artist, 'The Ghostly Ghouls'); - assert.equal(song.favorite, true); - assert.equal(song.hasBeenPlayed, false); - }) - - it.skip('should not be a favorite by default', function() { - var song = createSong('Witches\' Brew Boogie', 'The Ghostly Ghouls') - - assert.equal(song.favorite, false); - }) - - - it.skip('should be able to play a song', function() { - var song = createSong('I Put A Spell On You', 'Bette Midler, Sarah Jessica Parker & Kathy Najimy') - - assert.equal(song.name, 'I Put A Spell On You'); - assert.equal(song.artist, 'Bette Midler, Sarah Jessica Parker & Kathy Najimy'); - assert.equal(song.hasBeenPlayed, false); - assert.equal(song.favorite, false); - - var playedSong = playSong(song) - - assert.equal(playedSong.hasBeenPlayed, true); - }) - - it.skip('should be able to create a playlist', function() { - var skeletonSong = createSong('Skeletons in the Closet Rock', 'The Skeletal Band'); - var tangoTrack = createSong('Trick or Treat Tango', 'The Spooky Cats'); - - var playlist = makePlaylist('Halloween Songs', [skeletonSong, tangoTrack]); - - assert.equal(playlist.name, 'Halloween Songs'); - assert.deepEqual(playlist.songs, [skeletonSong, tangoTrack]) - }) - - it.skip('should be able to add songs to a playlist', function() { - var jingleJive = createSong('Jingle Bell Jive', 'The Dancing Elves'); - - var holidayPlaylist = makePlaylist('Holiday Songs', [jingleJive]); - - assert.equal(holidayPlaylist.name, 'Holiday Songs'); - assert.deepEqual(holidayPlaylist.songs, [jingleJive]) - - var funkyFrosty = createSong('Frosty\'s Funky Groove', 'The Snowmen Band'); - - var updatedHolidayPlaylist = addSongToPlaylist(holidayPlaylist, funkyFrosty); - - assert.deepEqual(updatedHolidayPlaylist.songs, [jingleJive, funkyFrosty]) - }) - - it.skip('should be able to play all the songs', function() { - var rockinSong = createSong('Rockin\' Around the Christmas Treehouse', 'The Yuletide Youth'); - var shuffleSong = createSong('Santa\'s Sleigh Ride Shuffle', 'The Jolly Jinglesters') - var reggaeSong = createSong('Rudolph\'s Reggae Jam', 'The Reindeer Rhythms') - - var holidayPlaylist = makePlaylist('Holiday Songs', [rockinSong, shuffleSong, reggaeSong]); - - var updatedHolidayPlaylist = playSongs(holidayPlaylist) - - assert.equal(updatedHolidayPlaylist.songs[0].hasBeenPlayed, true) - assert.equal(updatedHolidayPlaylist.songs[1].hasBeenPlayed, true) - assert.equal(updatedHolidayPlaylist.songs[2].hasBeenPlayed, true) - }) - - it.skip('should play only the favorite songs when "favorites only" is specified', function() { - // Create three songs, two of which are marked as favorites. - var rockinSong = createSong('Rockin\' Around the Christmas Treehouse', 'The Yuletide Youth', true); - var shuffleSong = createSong('Santa\'s Sleigh Ride Shuffle', 'The Jolly Jinglesters') - var reggaeSong = createSong('Rudolph\'s Reggae Jam', 'The Reindeer Rhythms', true) - - // Add all three songs to a holiday playlist. - var holidayPlaylist = makePlaylist('Holiday Songs', [rockinSong, shuffleSong, reggaeSong]); - // Play only the favorite songs in the playlist. - var updatedHolidayPlaylist = playSongs(holidayPlaylist, "favorites only") - // Assert that the favorite songs have been played, while the non-favorite hasn't. - assert.equal(updatedHolidayPlaylist.songs[0].hasBeenPlayed, true) - assert.equal(updatedHolidayPlaylist.songs[1].hasBeenPlayed, false) - assert.equal(updatedHolidayPlaylist.songs[2].hasBeenPlayed, true) - }) - -}) \ No newline at end of file +describe('dj', function () { + it('should be able to create songs', function () { + var song = createSong('Zombie Shuffle', 'The Creepy Crawlers', true); + + assert.equal(song.name, 'Zombie Shuffle'); + assert.equal(song.artist, 'The Creepy Crawlers'); + assert.equal(song.favorite, true); + }); + + it('should not have been played by default', function () { + var song = createSong("Witches' Brew Boogie", 'The Ghostly Ghouls', true); + + assert.equal(song.name, "Witches' Brew Boogie"); + assert.equal(song.artist, 'The Ghostly Ghouls'); + assert.equal(song.favorite, true); + assert.equal(song.hasBeenPlayed, false); + }); + + it('should not be a favorite by default', function () { + var song = createSong("Witches' Brew Boogie", 'The Ghostly Ghouls'); + + assert.equal(song.favorite, false); + }); + + it('should be able to play a song', function () { + var song = createSong( + 'I Put A Spell On You', + 'Bette Midler, Sarah Jessica Parker & Kathy Najimy' + ); + + assert.equal(song.name, 'I Put A Spell On You'); + assert.equal( + song.artist, + 'Bette Midler, Sarah Jessica Parker & Kathy Najimy' + ); + assert.equal(song.hasBeenPlayed, false); + assert.equal(song.favorite, false); + + var playedSong = playSong(song); + + assert.equal(playedSong.hasBeenPlayed, true); + }); + + it('should be able to create a playlist', function () { + var skeletonSong = createSong( + 'Skeletons in the Closet Rock', + 'The Skeletal Band' + ); + var tangoTrack = createSong('Trick or Treat Tango', 'The Spooky Cats'); + + var playlist = makePlaylist('Halloween Songs', [skeletonSong, tangoTrack]); + + assert.equal(playlist.name, 'Halloween Songs'); + assert.deepEqual(playlist.songs, [skeletonSong, tangoTrack]); + }); + + it('should be able to add songs to a playlist', function () { + var jingleJive = createSong('Jingle Bell Jive', 'The Dancing Elves'); + + var holidayPlaylist = makePlaylist('Holiday Songs', [jingleJive]); + + assert.equal(holidayPlaylist.name, 'Holiday Songs'); + assert.deepEqual(holidayPlaylist.songs, [jingleJive]); + + var funkyFrosty = createSong("Frosty's Funky Groove", 'The Snowmen Band'); + + var updatedHolidayPlaylist = addSongToPlaylist( + holidayPlaylist, + funkyFrosty + ); + + assert.deepEqual(updatedHolidayPlaylist.songs, [jingleJive, funkyFrosty]); + }); + + it('should be able to play all the songs', function () { + var rockinSong = createSong( + "Rockin' Around the Christmas Treehouse", + 'The Yuletide Youth' + ); + var shuffleSong = createSong( + "Santa's Sleigh Ride Shuffle", + 'The Jolly Jinglesters' + ); + var reggaeSong = createSong("Rudolph's Reggae Jam", 'The Reindeer Rhythms'); + + var holidayPlaylist = makePlaylist('Holiday Songs', [ + rockinSong, + shuffleSong, + reggaeSong, + ]); + + var updatedHolidayPlaylist = playSongs(holidayPlaylist); + + assert.equal(updatedHolidayPlaylist.songs[0].hasBeenPlayed, true); + assert.equal(updatedHolidayPlaylist.songs[1].hasBeenPlayed, true); + assert.equal(updatedHolidayPlaylist.songs[2].hasBeenPlayed, true); + }); + + it('should play only the favorite songs when "favorites only" is specified', function () { + // Create three songs, two of which are marked as favorites. + var rockinSong = createSong( + "Rockin' Around the Christmas Treehouse", + 'The Yuletide Youth', + true + ); + var shuffleSong = createSong( + "Santa's Sleigh Ride Shuffle", + 'The Jolly Jinglesters' + ); + var reggaeSong = createSong( + "Rudolph's Reggae Jam", + 'The Reindeer Rhythms', + true + ); + + // Add all three songs to a holiday playlist. + var holidayPlaylist = makePlaylist('Holiday Songs', [ + rockinSong, + shuffleSong, + reggaeSong, + ]); + // Play only the favorite songs in the playlist. + var updatedHolidayPlaylist = playSongs(holidayPlaylist, 'favorites only'); + // Assert that the favorite songs have been played, while the non-favorite hasn't. + assert.equal(updatedHolidayPlaylist.songs[0].hasBeenPlayed, true); + assert.equal(updatedHolidayPlaylist.songs[1].hasBeenPlayed, false); + assert.equal(updatedHolidayPlaylist.songs[2].hasBeenPlayed, true); + }); +}); diff --git a/dj/dj.js b/dj/dj.js index cc8947f70..5460112a2 100644 --- a/dj/dj.js +++ b/dj/dj.js @@ -1,8 +1,45 @@ +function createSong(name, artist, favorite = false, hasBeenPlayed = false) { + return { + name, + artist, + favorite, + hasBeenPlayed, + }; +} -module.exports = { - // createSong, - // playSong, - // makePlaylist, - // addSongToPlaylist, - // playSongs +function playSong(song) { + song.hasBeenPlayed = true; + return song; +} + +function makePlaylist(name, songs) { + return { name, songs }; +} + +function addSongToPlaylist(playlist, song) { + playlist.songs.push(song); + return playlist; +} + +function playSongs(playlist, specifiedSongs) { + // updates all songs when specifiedSongs is not included + // updates favorites only when specified songs === 'favorites only' + playlist.songs.forEach(function (song) { + if ( + !specifiedSongs || + (specifiedSongs === 'favorites only' && song.favorite) + ) { + song.hasBeenPlayed = true; + } + }); + + return playlist; +} + +module.exports = { + createSong, + playSong, + makePlaylist, + addSongToPlaylist, + playSongs, }; diff --git a/favorite-foods/favorite-foods-test.js b/favorite-foods/favorite-foods-test.js index bc5f7985b..6bc69a5f0 100644 --- a/favorite-foods/favorite-foods-test.js +++ b/favorite-foods/favorite-foods-test.js @@ -1,92 +1,245 @@ -var { createFavoriteFood } = require('./favorite-foods'); +var { createFavoriteFood, commentOnSpiciness, orderFood, createShoppingList } = require('./favorite-foods'); var assert = require('chai').assert; describe('favorite foods', function () { - it.skip('should create a new dish with a name', function () { - var pizza = createFavoriteFood({ dish: 'Pizza' }); - - assert.equal(pizza.name, 'Pizza'); - }); - - it.skip('should be able to create a different dish', function () { - var smoothie = createFavoriteFood({ dish: 'Smoothie' }); - - assert.equal(smoothie.name, 'Smoothie'); - }); - - it.skip('should have ingredients', function () { - var tacos = createFavoriteFood({ dish: 'Tacos', ingredients: ['Tortilla', 'Ground Beef', 'Lettuce', 'Tomatoes', 'Sour Cream', 'Salsa'] }); - - assert.equal(tacos.name, 'Tacos'); - assert.deepEqual(tacos.ingredients, ['Tortilla', 'Ground Beef', 'Lettuce', 'Tomatoes', 'Sour Cream', 'Salsa']); - }); - - it.skip('should be able to have different ingredients', function () { - var burger = createFavoriteFood({ dish: 'Burger', ingredients: ['Bun', 'Beef Patty', 'Lettuce', 'Tomato', 'Cheese', 'Ketchup', 'Mustard'] }); - var sushi = createFavoriteFood({ dish: 'Sushi', ingredients: ['Rice', 'Salmon', 'Tuna', 'Avocado', 'Cucumber', 'Soy Sauce', 'Wasabi'] }); - - assert.equal(burger.name, 'Burger'); - assert.deepEqual(burger.ingredients, ['Bun', 'Beef Patty', 'Lettuce', 'Tomato', 'Cheese', 'Ketchup', 'Mustard']); - - assert.equal(sushi.name, 'Sushi'); - assert.deepEqual(sushi.ingredients, ['Rice', 'Salmon', 'Tuna', 'Avocado', 'Cucumber', 'Soy Sauce', 'Wasabi']); - }); - - it.skip('should be spicy or not', function () { - var pancakes = createFavoriteFood({ dish: 'Pancakes', ingredients: ['Flour', 'Egg', 'Milk', 'Butter', 'Maple Syrup'], isSpicy: false }); - var padThai = createFavoriteFood({ dish: 'Pad Thai', ingredients: ['Rice Noodles', 'Shrimp', 'Tofu', 'Egg', 'Bean Sprouts', 'Peanuts', 'Lime'], isSpicy: true }); - - assert.equal(pancakes.name, 'Pancakes'); - assert.deepEqual(pancakes.ingredients, ['Flour', 'Egg', 'Milk', 'Butter', 'Maple Syrup']); - assert.equal(pancakes.isSpicy, false); - - assert.equal(padThai.name, 'Pad Thai'); - assert.deepEqual(padThai.ingredients, ['Rice Noodles', 'Shrimp', 'Tofu', 'Egg', 'Bean Sprouts', 'Peanuts', 'Lime']); - assert.equal(padThai.isSpicy, true); - }); - - it.skip('should be able to taste the food and comment on how spicy it is', function () { - var dish1 = createFavoriteFood({ dish: 'Pho', ingredients: ['Rice Noodles', 'Beef', 'Bean Sprouts', 'Basil', 'Lime', 'Sriracha'], isSpicy: true }); - var dish2 = createFavoriteFood({ dish: 'Lasagna', ingredients: ['Lasagna Noodles', 'Ground Beef', 'Tomato Sauce', 'Ricotta Cheese', 'Mozzarella Cheese'], isSpicy: false }); - - var comment1 = commentOnSpiciness(dish1); - var comment2 = commentOnSpiciness(dish2); - - assert.equal(comment1, 'Wow, this Pho is so spicy!'); - assert.equal(comment2, 'Phew, this Lasagna is not very spicy.'); - }); - - it.skip('should start off having ordered 0 times', function () { - var dish = createFavoriteFood('Falafel', ['Chickpeas', 'Garlic', 'Onion', 'Cumin', 'Tahini', 'Pita Bread'], true); - - assert.equal(dish.timesOrdered, 0); - }); - - it.skip('should be able to order dishes', function () { - var dish1 = createFavoriteFood({ dish: 'Fish and Chips', ingredients: ['Fish Fillet', 'Potatoes', 'Flour', 'Egg', 'Beer', 'Tartar Sauce'], isSpicy: false }); - var dish2 = createFavoriteFood({ dish: 'Chicken Curry', ingredients: ['Chicken', 'Coconut Milk', 'Onion', 'Garlic', 'Rice'], isSpicy: true }); - var dish3 = createFavoriteFood({ dish: 'Ice Cream', ingredients: ['Milk', 'Cream', 'Sugar', 'Vanilla Extract', 'Chocolate Chips'], isSpicy: false }); - - var orderedDish1 = orderFood(dish1); - var orderedDish2 = orderFood(dish2); - var orderedDish3 = orderFood(dish3); - - assert.equal(orderedDish1.timesOrdered, 1); - assert.equal(orderedDish2.timesOrdered, 1); - assert.equal(orderedDish3.timesOrdered, 1); - - var anotherOrder = orderFood(orderedDish3); - - assert.equal(anotherOrder.timesOrdered, 2); - }) - - // spicy ๐ŸŒถ๏ธ - it.skip('should be able to make a list of all ingredients needed for multiple dishes', function () { - var pizza = createFavoriteFood({ dish: 'Pizza', ingredients: ['Tomato Sauce', 'Cheese', 'Pepperoni', 'Mushrooms'], isSpicy: false }); - var smoothie = createFavoriteFood({ dish: 'Smoothie', ingredients: ['Banana', 'Strawberry', 'Blueberry', 'Milk', 'Honey'], isSpicy: false }) - - var list = createShoppingList([pizza, smoothie]) - - assert.deepEqual(list, ['Tomato Sauce', 'Cheese', 'Pepperoni', 'Mushrooms', 'Banana', 'Strawberry', 'Blueberry', 'Milk', 'Honey']) - }); -}); \ No newline at end of file + it('should create a new dish with a name', function () { + var pizza = createFavoriteFood({ dish: 'Pizza' }); + + assert.equal(pizza.name, 'Pizza'); + }); + + it('should be able to create a different dish', function () { + var smoothie = createFavoriteFood({ dish: 'Smoothie' }); + + assert.equal(smoothie.name, 'Smoothie'); + }); + + it('should have ingredients', function () { + var tacos = createFavoriteFood({ + dish: 'Tacos', + ingredients: [ + 'Tortilla', + 'Ground Beef', + 'Lettuce', + 'Tomatoes', + 'Sour Cream', + 'Salsa', + ], + }); + + assert.equal(tacos.name, 'Tacos'); + assert.deepEqual(tacos.ingredients, [ + 'Tortilla', + 'Ground Beef', + 'Lettuce', + 'Tomatoes', + 'Sour Cream', + 'Salsa', + ]); + }); + + it('should be able to have different ingredients', function () { + var burger = createFavoriteFood({ + dish: 'Burger', + ingredients: [ + 'Bun', + 'Beef Patty', + 'Lettuce', + 'Tomato', + 'Cheese', + 'Ketchup', + 'Mustard', + ], + }); + var sushi = createFavoriteFood({ + dish: 'Sushi', + ingredients: [ + 'Rice', + 'Salmon', + 'Tuna', + 'Avocado', + 'Cucumber', + 'Soy Sauce', + 'Wasabi', + ], + }); + + assert.equal(burger.name, 'Burger'); + assert.deepEqual(burger.ingredients, [ + 'Bun', + 'Beef Patty', + 'Lettuce', + 'Tomato', + 'Cheese', + 'Ketchup', + 'Mustard', + ]); + + assert.equal(sushi.name, 'Sushi'); + assert.deepEqual(sushi.ingredients, [ + 'Rice', + 'Salmon', + 'Tuna', + 'Avocado', + 'Cucumber', + 'Soy Sauce', + 'Wasabi', + ]); + }); + + it('should be spicy or not', function () { + var pancakes = createFavoriteFood({ + dish: 'Pancakes', + ingredients: ['Flour', 'Egg', 'Milk', 'Butter', 'Maple Syrup'], + isSpicy: false, + }); + var padThai = createFavoriteFood({ + dish: 'Pad Thai', + ingredients: [ + 'Rice Noodles', + 'Shrimp', + 'Tofu', + 'Egg', + 'Bean Sprouts', + 'Peanuts', + 'Lime', + ], + isSpicy: true, + }); + + assert.equal(pancakes.name, 'Pancakes'); + assert.deepEqual(pancakes.ingredients, [ + 'Flour', + 'Egg', + 'Milk', + 'Butter', + 'Maple Syrup', + ]); + assert.equal(pancakes.isSpicy, false); + + assert.equal(padThai.name, 'Pad Thai'); + assert.deepEqual(padThai.ingredients, [ + 'Rice Noodles', + 'Shrimp', + 'Tofu', + 'Egg', + 'Bean Sprouts', + 'Peanuts', + 'Lime', + ]); + assert.equal(padThai.isSpicy, true); + }); + + it('should be able to taste the food and comment on how spicy it is', function () { + var dish1 = createFavoriteFood({ + dish: 'Pho', + ingredients: [ + 'Rice Noodles', + 'Beef', + 'Bean Sprouts', + 'Basil', + 'Lime', + 'Sriracha', + ], + isSpicy: true, + }); + var dish2 = createFavoriteFood({ + dish: 'Lasagna', + ingredients: [ + 'Lasagna Noodles', + 'Ground Beef', + 'Tomato Sauce', + 'Ricotta Cheese', + 'Mozzarella Cheese', + ], + isSpicy: false, + }); + + var comment1 = commentOnSpiciness(dish1); + var comment2 = commentOnSpiciness(dish2); + + assert.equal(comment1, 'Wow, this Pho is so spicy!'); + assert.equal(comment2, 'Phew, this Lasagna is not very spicy.'); + }); + + it('should start off having ordered 0 times', function () { + var dish = createFavoriteFood( + 'Falafel', + ['Chickpeas', 'Garlic', 'Onion', 'Cumin', 'Tahini', 'Pita Bread'], + true + ); + + assert.equal(dish.timesOrdered, 0); + }); + + it('should be able to order dishes', function () { + var dish1 = createFavoriteFood({ + dish: 'Fish and Chips', + ingredients: [ + 'Fish Fillet', + 'Potatoes', + 'Flour', + 'Egg', + 'Beer', + 'Tartar Sauce', + ], + isSpicy: false, + }); + var dish2 = createFavoriteFood({ + dish: 'Chicken Curry', + ingredients: ['Chicken', 'Coconut Milk', 'Onion', 'Garlic', 'Rice'], + isSpicy: true, + }); + var dish3 = createFavoriteFood({ + dish: 'Ice Cream', + ingredients: [ + 'Milk', + 'Cream', + 'Sugar', + 'Vanilla Extract', + 'Chocolate Chips', + ], + isSpicy: false, + }); + + var orderedDish1 = orderFood(dish1); + var orderedDish2 = orderFood(dish2); + var orderedDish3 = orderFood(dish3); + + assert.equal(orderedDish1.timesOrdered, 1); + assert.equal(orderedDish2.timesOrdered, 1); + assert.equal(orderedDish3.timesOrdered, 1); + + var anotherOrder = orderFood(orderedDish3); + + assert.equal(anotherOrder.timesOrdered, 2); + }); + + // spicy ๐ŸŒถ๏ธ + it('should be able to make a list of all ingredients needed for multiple dishes', function () { + var pizza = createFavoriteFood({ + dish: 'Pizza', + ingredients: ['Tomato Sauce', 'Cheese', 'Pepperoni', 'Mushrooms'], + isSpicy: false, + }); + var smoothie = createFavoriteFood({ + dish: 'Smoothie', + ingredients: ['Banana', 'Strawberry', 'Blueberry', 'Milk', 'Honey'], + isSpicy: false, + }); + + var list = createShoppingList([pizza, smoothie]); + + assert.deepEqual(list, [ + 'Tomato Sauce', + 'Cheese', + 'Pepperoni', + 'Mushrooms', + 'Banana', + 'Strawberry', + 'Blueberry', + 'Milk', + 'Honey', + ]); + }); +}); diff --git a/favorite-foods/favorite-foods.js b/favorite-foods/favorite-foods.js index 5f93c3872..286c0158c 100644 --- a/favorite-foods/favorite-foods.js +++ b/favorite-foods/favorite-foods.js @@ -1,4 +1,42 @@ +function createFavoriteFood(food) { + return { + name: food.dish, + ingredients: food.ingredients, + isSpicy: food.isSpicy, + timesOrdered: 0, + }; +} +function commentOnSpiciness(food) { + if (food.isSpicy) { + return `Wow, this ${food.name} is so spicy!`; + } + return `Phew, this ${food.name} is not very spicy.`; +} -module.exports = { }; \ No newline at end of file +function orderFood(food) { + food.timesOrdered += 1; + return food; +} + +function createShoppingList(foods) { + const ingredients = []; + + var ingredient; + for (let i = 0; i < foods.length; i += 1) { + for (let j = 0; j < foods[i].ingredients.length; j += 1) { + ingredient = foods[i].ingredients[j]; + if (!ingredients.includes(ingredient)) ingredients.push(ingredient); + } + } + + return ingredients; +} + +module.exports = { + createFavoriteFood, + commentOnSpiciness, + orderFood, + createShoppingList, +}; diff --git a/mythical-creatures/README.md b/mythical-creatures/README.md index d8afeb7f8..300c379cc 100644 --- a/mythical-creatures/README.md +++ b/mythical-creatures/README.md @@ -12,9 +12,9 @@ Run the command `npm test mythical-creatures/test/dragon-test.js`. To run other ### Creature Order -- [ ] `dragon` -- [ ] `vampire` -- [ ] `hobbit` +- [x] `dragon` +- [x] `vampire` +- [x] `hobbit` ### Extra Challenge: Make a New Creature! diff --git a/mythical-creatures/exercises/dragon.js b/mythical-creatures/exercises/dragon.js index 0037230de..0fa683d60 100644 --- a/mythical-creatures/exercises/dragon.js +++ b/mythical-creatures/exercises/dragon.js @@ -1,8 +1,37 @@ +function createDragon(name, rider, temperment) { + return { + name, + rider, + temperment, + timesEaten: 0, + hungry: true, + }; +} +function greetRider(dragon) { + return `Hi, ${dragon.rider}!`; +} + +function eat(dragon) { + dragon.timesEaten += 1; + if (dragon.timesEaten > 2) dragon.hungry = false; + + return dragon; +} + +function findFireBreathers(dragons) { + var fireBreathers = [] + + for (let i = 0; i < dragons.length; i += 1) { + if (dragons[i].temperment === 'aggressive') fireBreathers.push(dragons[i]) + } + + return fireBreathers; +} module.exports = { - // createDragon, - // greetRider, - // eat, - // findFireBreathers -} \ No newline at end of file + createDragon, + greetRider, + eat, + findFireBreathers, +}; diff --git a/mythical-creatures/exercises/hobbit.js b/mythical-creatures/exercises/hobbit.js index 6d9602430..3931628fd 100644 --- a/mythical-creatures/exercises/hobbit.js +++ b/mythical-creatures/exercises/hobbit.js @@ -1,9 +1,51 @@ +function createHobbit(name = 'unknown', age = 0) { + return { + name, + age, + isAdult: age > 32, + isOld: age > 100, + acquaintances: [], + }; +} +function celebrateBirthday(hobbit) { + hobbit.age += 1; + + if (hobbit.age > 32) hobbit.isAdult = true; + if (hobbit.age > 100) hobbit.isOld = true; + + return hobbit; +} + +function getRing(hobbit) { + if (hobbit.name === 'Frodo') { + return 'Here is the ring!'; + } + + return "You can't have it!"; +} + +function meetPeople(hobbit, people) { + hobbit.acquaintances = hobbit.acquaintances.concat(people); + return hobbit; +} + +function findFriends(hobbit) { + var friends = []; + + for (let i = 0; i < hobbit.acquaintances.length; i += 1) { + if (hobbit.acquaintances[i].relationship === 'friend') { + friends.push(hobbit.acquaintances[i].name); + } + } + + return friends; +} module.exports = { - // createHobbit, - // celebrateBirthday, - // getRing, - // meetPeople, - // findFriends -} \ No newline at end of file + createHobbit, + celebrateBirthday, + getRing, + meetPeople, + findFriends, +}; diff --git a/mythical-creatures/exercises/vampire.js b/mythical-creatures/exercises/vampire.js index 930b9e5cc..29708abd6 100644 --- a/mythical-creatures/exercises/vampire.js +++ b/mythical-creatures/exercises/vampire.js @@ -1,9 +1,51 @@ +function createVampire(name, pet = 'bat') { + return { + name, + pet, + thirsty: true, + ouncesDrank: 0, + }; +} +function drink(vampire) { + if (vampire.thirsty) { + vampire.ouncesDrank += 10; + if (vampire.ouncesDrank >= 50) vampire.thirsty = false; + } + + return vampire; +} + +function findBatLovers(vampires) { + var batLovers = []; + + for (let i = 0; i < vampires.length; i += 1) { + if (vampires[i].pet === 'bat') batLovers.push(vampires[i].name); + } + + return batLovers; +} + +function encounterDeliciousVictim(vampire) { + if (vampire.thirsty) return 'I WANT TO SUCK YOUR BLOOD!'; + + return 'No thanks, I am too full.'; +} + +function inquirePlace(locations, location) { + for (let i = 0; i < locations.length; i += 1) { + if (locations[i] === location) { + return `Yes, I have spent some time in ${location}.`; + } + } + + return 'No, I have never been to Idaho.'; +} module.exports = { - // createVampire, - // drink, - // findBatLovers, - // encounterDeliciousVictim, - // inquirePlace -} \ No newline at end of file + createVampire, + drink, + findBatLovers, + encounterDeliciousVictim, + inquirePlace, +}; diff --git a/mythical-creatures/test/dragon-test.js b/mythical-creatures/test/dragon-test.js index c5f035bd4..c568ed6b3 100644 --- a/mythical-creatures/test/dragon-test.js +++ b/mythical-creatures/test/dragon-test.js @@ -1,35 +1,39 @@ var assert = require('chai').assert; -var { createDragon, greetRider, eat, findFireBreathers} = require('../exercises/dragon'); - -describe('Dragon', function() { - - it.skip('should be able to create a dragon with a name', function() { +var { + createDragon, + greetRider, + eat, + findFireBreathers, +} = require('../exercises/dragon'); + +describe('Dragon', function () { + it('should be able to create a dragon with a name', function () { var dragon = createDragon('Jeff'); assert.equal(dragon.name, 'Jeff'); }); - it.skip('should be able to have a different name', function() { + it('should be able to have a different name', function () { var dragon = createDragon('Louisa'); assert.equal(dragon.name, 'Louisa'); }); - it.skip('should have a rider', function() { + it('should have a rider', function () { var dragon = createDragon('Saphira', 'Eragon'); assert.equal(dragon.name, 'Saphira'); assert.equal(dragon.rider, 'Eragon'); }); - it.skip('should be able to have a different rider', function() { + it('should be able to have a different rider', function () { var dragon = createDragon('Elliot', 'Pete'); assert.equal(dragon.name, 'Elliot'); assert.equal(dragon.rider, 'Pete'); }); - it.skip('should have a temperment', function() { + it('should have a temperment', function () { var dragon = createDragon('Saphira', 'Eragon', 'gentle'); assert.equal(dragon.name, 'Saphira'); @@ -37,11 +41,10 @@ describe('Dragon', function() { assert.equal(dragon.temperment, 'gentle'); }); - it.skip('should be able to have different temperments', function() { + it('should be able to have different temperments', function () { var dragon1 = createDragon('Gray', 'Marley', 'aggressive'); var dragon2 = createDragon('Sky', 'Susie', 'gentle'); - assert.equal(dragon1.name, 'Gray'); assert.equal(dragon1.rider, 'Marley'); assert.equal(dragon1.temperment, 'aggressive'); @@ -51,7 +54,7 @@ describe('Dragon', function() { assert.equal(dragon2.temperment, 'gentle'); }); - it.skip('should greet their rider', function() { + it('should greet their rider', function () { var dragon1 = createDragon('Gray', 'Marley', 'aggressive'); var dragon2 = createDragon('Sky', 'Susie', 'gentle'); @@ -62,19 +65,19 @@ describe('Dragon', function() { assert.equal(greeting2, 'Hi, Susie!'); }); - it.skip('should start off having eaten 0 times', function() { + it('should start off having eaten 0 times', function () { var dragon = createDragon('Mushu', 'Mulan', 'aggressive'); assert.equal(dragon.timesEaten, 0); }); - it.skip('should start off being hungry', function() { + it('should start off being hungry', function () { var dragon = createDragon('Mushu', 'Mulan', 'aggressive'); assert.equal(dragon.hungry, true); }); - it.skip('should be full after eating 3 times', function() { + it('should be full after eating 3 times', function () { var dragon = createDragon('Lady Vox', 'Emily', 'gentle'); var fedDragon = eat(dragon); @@ -94,16 +97,16 @@ describe('Dragon', function() { }); //Spicy: - it.skip('should be a fireBreather if aggressive in temperment', function() { + it('should be a fireBreather if aggressive in temperment', function () { var dragon1 = createDragon('Gray', 'Marley', 'aggressive'); var dragon2 = createDragon('Sky', 'Susie', 'gentle'); var dragon3 = createDragon('Mushu', 'Mulan', 'aggressive'); var dragon4 = createDragon('Lady Vox', 'Emily', 'gentle'); var allDragons = [dragon1, dragon2, dragon3, dragon4]; - + var fireBreathers = findFireBreathers(allDragons); - assert.deepEqual(fireBreathers, [dragon1, dragon3]) + assert.deepEqual(fireBreathers, [dragon1, dragon3]); }); }); diff --git a/mythical-creatures/test/hobbit-test.js b/mythical-creatures/test/hobbit-test.js index fa53686c0..a03bc250e 100644 --- a/mythical-creatures/test/hobbit-test.js +++ b/mythical-creatures/test/hobbit-test.js @@ -1,9 +1,14 @@ var assert = require('chai').assert; -var {createHobbit, celebrateBirthday, getRing, meetPeople, findFriends} = require('../exercises/hobbit'); - -describe('Hobbit', function() { - - it.skip('should make a hobbit with a name and age', function() { +var { + createHobbit, + celebrateBirthday, + getRing, + meetPeople, + findFriends, +} = require('../exercises/hobbit'); + +describe('Hobbit', function () { + it('should make a hobbit with a name and age', function () { var bilbo = createHobbit('Bilbo', 0); var mark = createHobbit('Mark', 5); @@ -14,20 +19,20 @@ describe('Hobbit', function() { assert.equal(mark.age, 5); }); - it.skip('should start out 0 years old if not specified', function() { + it('should start out 0 years old if not specified', function () { var bilbo = createHobbit('Bilbo'); assert.equal(bilbo.age, 0); }); - it.skip('should return an object with defaults if nothing passed', function() { + it('should return an object with defaults if nothing passed', function () { var hobbit = createHobbit(); assert.equal(hobbit.name, 'unknown'); assert.equal(hobbit.age, 0); }); - it.skip('should gain 1 year after every birthday', function() { + it('should gain 1 year after every birthday', function () { var hobbit = createHobbit('Meriadoc'); var olderHobbit = celebrateBirthday(hobbit); @@ -37,19 +42,19 @@ describe('Hobbit', function() { assert.equal(evenOlderStillHobbit.age, 3); }); - it.skip('should be considered a child at the age of 32', function() { + it('should be considered a child at the age of 32', function () { var taylor = createHobbit('Taylor', 31); assert.equal(taylor.age, 31); assert.equal(taylor.isAdult, false); - var olderTaylor = celebrateBirthday(taylor) + var olderTaylor = celebrateBirthday(taylor); assert.equal(olderTaylor.age, 32); assert.equal(olderTaylor.isAdult, false); }); - it.skip('should be considered an adult at 33', function() { + it('should be considered an adult at 33', function () { var ryan = createHobbit('Ryan', 32); var olderRyan = celebrateBirthday(ryan); @@ -58,32 +63,32 @@ describe('Hobbit', function() { assert.equal(olderRyan.isAdult, true); }); - it.skip('should be considered old at the age of 101', function() { + it('should be considered old at the age of 101', function () { var samwise = createHobbit('Samwise', 99); - assert.equal(samwise.age, 99) - assert.equal(samwise.isOld, false) + assert.equal(samwise.age, 99); + assert.equal(samwise.isOld, false); var hundredYearOldSamwise = celebrateBirthday(samwise); - assert.equal(hundredYearOldSamwise.age, 100) - assert.equal(hundredYearOldSamwise.isOld, false) + assert.equal(hundredYearOldSamwise.age, 100); + assert.equal(hundredYearOldSamwise.isOld, false); var hundredAndOneSamwise = celebrateBirthday(hundredYearOldSamwise); assert.equal(hundredAndOneSamwise.age, 101); - assert.equal(hundredAndOneSamwise.isOld, true) + assert.equal(hundredAndOneSamwise.isOld, true); }); - it.skip('should be able to get the ring if its name is Frodo', function() { + it('should be able to get the ring if its name is Frodo', function () { var hobbit1 = createHobbit('Frodo'); var hobbit2 = createHobbit('Samwise'); assert.equal(getRing(hobbit1), 'Here is the ring!'); - assert.equal(getRing(hobbit2), 'You can\'t have it!'); + assert.equal(getRing(hobbit2), "You can't have it!"); }); - it.skip('should start with no acquaintances', function() { + it('should start with no acquaintances', function () { var bilbo = createHobbit('Bilbo'); assert.equal(bilbo.name, 'Bilbo'); @@ -91,12 +96,12 @@ describe('Hobbit', function() { assert.deepEqual(bilbo.acquaintances, []); }); - //Spicy - it.skip('should be able to meet people', function() { - var people = [ {name: 'Nick', relationship: 'friend'} ]; + //Spicy + it('should be able to meet people', function () { + var people = [{ name: 'Nick', relationship: 'friend' }]; var bilbo = createHobbit('Bilbo'); - var socialBilbo = meetPeople(bilbo, people) + var socialBilbo = meetPeople(bilbo, people); assert.equal(socialBilbo.name, 'Bilbo'); assert.equal(socialBilbo.acquaintances.length, 1); @@ -104,54 +109,68 @@ describe('Hobbit', function() { assert.equal(socialBilbo.acquaintances[0].relationship, 'friend'); }); - it.skip('should be able to meet several people at once', function() { - var people = [ {name: 'Nick', relationship: 'friend'}, {name: 'Ben', relationship: 'enemy'} ]; + it('should be able to meet several people at once', function () { + var people = [ + { name: 'Nick', relationship: 'friend' }, + { name: 'Ben', relationship: 'enemy' }, + ]; var bilbo = createHobbit('Bilbo'); - var socialBilbo = meetPeople(bilbo, people) + var socialBilbo = meetPeople(bilbo, people); assert.equal(socialBilbo.name, 'Bilbo'); assert.equal(socialBilbo.acquaintances.length, 2); - assert.deepEqual(socialBilbo.acquaintances[0], {name: 'Nick', relationship: 'friend'}); - assert.deepEqual(socialBilbo.acquaintances[1], {name: 'Ben', relationship: 'enemy'}); + assert.deepEqual(socialBilbo.acquaintances[0], { + name: 'Nick', + relationship: 'friend', + }); + assert.deepEqual(socialBilbo.acquaintances[1], { + name: 'Ben', + relationship: 'enemy', + }); assert.deepEqual(socialBilbo.acquaintances, people); }); - it.skip('should be able to meet people on multiple occasions', function() { - var nick = {name: 'Nick', relationship: 'friend'}; - var ben = {name: 'Ben', relationship: 'enemy'}; - var people = [ nick, ben ]; + it('should be able to meet people on multiple occasions', function () { + var nick = { name: 'Nick', relationship: 'friend' }; + var ben = { name: 'Ben', relationship: 'enemy' }; + var people = [nick, ben]; var bilbo = createHobbit('Bilbo'); - var socialBilbo = meetPeople(bilbo, people) + var socialBilbo = meetPeople(bilbo, people); assert.equal(socialBilbo.acquaintances.length, 2); assert.deepEqual(socialBilbo.acquaintances, people); - var trisha = {name: 'Trisha', relationship: 'enemy'}; - var dustin = {name: 'Dustin', relationship: 'friend'}; - var morePeople = [ trisha, dustin ]; + var trisha = { name: 'Trisha', relationship: 'enemy' }; + var dustin = { name: 'Dustin', relationship: 'friend' }; + var morePeople = [trisha, dustin]; var moreSocialBilbo = meetPeople(socialBilbo, morePeople); assert.equal(moreSocialBilbo.acquaintances.length, 4); - assert.deepEqual(moreSocialBilbo.acquaintances, [nick, ben, trisha, dustin]); + assert.deepEqual(moreSocialBilbo.acquaintances, [ + nick, + ben, + trisha, + dustin, + ]); }); - it.skip('should be able to identify which acquaintances are friends ', function() { - var foster = {name: 'Foster', relationship: 'friend'}; - var allie = {name: 'Allie', relationship: 'enemy'}; - var garrett = {name: 'Garrett', relationship: 'enemy'}; - var dustin = {name: 'Dustin', relationship: 'friend'}; - + it('should be able to identify which acquaintances are friends ', function () { + var foster = { name: 'Foster', relationship: 'friend' }; + var allie = { name: 'Allie', relationship: 'enemy' }; + var garrett = { name: 'Garrett', relationship: 'enemy' }; + var dustin = { name: 'Dustin', relationship: 'friend' }; + var bilbo = createHobbit('Bilbo'); - var socialBilbo = meetPeople(bilbo, [foster, allie, garrett, dustin]) + var socialBilbo = meetPeople(bilbo, [foster, allie, garrett, dustin]); - var friends = findFriends(socialBilbo) + var friends = findFriends(socialBilbo); assert.equal(friends.length, 2); - assert.equal(friends[0], "Foster"); - assert.equal(friends[1], "Dustin"); - assert.deepEqual(friends, ["Foster", "Dustin"]); + assert.equal(friends[0], 'Foster'); + assert.equal(friends[1], 'Dustin'); + assert.deepEqual(friends, ['Foster', 'Dustin']); }); }); diff --git a/mythical-creatures/test/vampire-test.js b/mythical-creatures/test/vampire-test.js index 8cf69f524..5343221f8 100644 --- a/mythical-creatures/test/vampire-test.js +++ b/mythical-creatures/test/vampire-test.js @@ -1,22 +1,27 @@ var assert = require('chai').assert; -var {createVampire, drink, findBatLovers, encounterDeliciousVictim, inquirePlace} = require('../exercises/vampire'); - -describe('Vampire', function() { - - it.skip('should create a vampire', function() { +var { + createVampire, + drink, + findBatLovers, + encounterDeliciousVictim, + inquirePlace, +} = require('../exercises/vampire'); + +describe('Vampire', function () { + it('should create a vampire', function () { var vampire = createVampire('Jhun'); assert.equal(vampire.name, 'Jhun'); }); - it.skip('should have a pet bat as a default', function() { + it('should have a pet bat as a default', function () { var vampire = createVampire('Brittany'); assert.equal(vampire.name, 'Brittany'); assert.equal(vampire.pet, 'bat'); }); - it.skip('should be able to take an argument for pet', function() { + it('should be able to take an argument for pet', function () { var vampire = createVampire('Jeff', 'fox'); var vampira = createVampire('Esme', 'armadillo'); @@ -24,26 +29,26 @@ describe('Vampire', function() { assert.equal(vampira.pet, 'armadillo'); }); - it.skip('should be thirsty', function() { + it('should be thirsty', function () { var vampire = createVampire('Andy'); assert.equal(vampire.thirsty, true); }); - it.skip('should shout at victim when thirsty', function() { + it('should shout at victim when thirsty', function () { var vampire = createVampire('Andy'); - var expectedResponse = 'I WANT TO SUCK YOUR BLOOD!' + var expectedResponse = 'I WANT TO SUCK YOUR BLOOD!'; - var shout = encounterDeliciousVictim(vampire) + var shout = encounterDeliciousVictim(vampire); assert.equal(shout, expectedResponse); }); - it.skip('should start with no ounces of blood drank', function() { + it('should start with no ounces of blood drank', function () { assert.equal(createVampire('Bobby').ouncesDrank, 0); }); - it.skip('should drink 10 ounces of blood at a time', function() { + it('should drink 10 ounces of blood at a time', function () { var vampire = createVampire('Margot'); var drankOnceVamp = drink(vampire); @@ -59,7 +64,7 @@ describe('Vampire', function() { assert.equal(drankThriceVamp.ouncesDrank, 30); }); - it.skip('should no longer be thirsty after drinking 50 ounces', function() { + it('should no longer be thirsty after drinking 50 ounces', function () { var vampire = createVampire('Javi'); var drankOnceVamp = drink(vampire); @@ -72,7 +77,7 @@ describe('Vampire', function() { assert.equal(drank5xsVamp.thirsty, false); }); - it.skip('should not drink more ounces when not thirsty', function() { + it('should not drink more ounces when not thirsty', function () { var vampire = createVampire('Javi'); var drankOnceVamp = drink(vampire); @@ -89,7 +94,7 @@ describe('Vampire', function() { assert.equal(notDrinking6xsVamp.ouncesDrank, 50); }); - it.skip('should refuse blood from victim when not thirsty', function() { + it('should refuse blood from victim when not thirsty', function () { var vampire = createVampire('Javi'); var drankOnceVamp = drink(vampire); @@ -101,28 +106,41 @@ describe('Vampire', function() { assert.equal(drank5xsVamp.ouncesDrank, 50); assert.equal(drank5xsVamp.thirsty, false); - assert.equal(encounterDeliciousVictim(drank5xsVamp), `No thanks, I am too full.`); + assert.equal( + encounterDeliciousVictim(drank5xsVamp), + `No thanks, I am too full.` + ); }); - it.skip('should say if its been to a location', function() { - var locations = ['Transylvania', 'Washington', 'New Orleans', 'Mystic Falls']; + it('should say if its been to a location', function () { + var locations = [ + 'Transylvania', + 'Washington', + 'New Orleans', + 'Mystic Falls', + ]; var response = inquirePlace(locations, 'New Orleans'); - var expectedResponse = "Yes, I have spent some time in New Orleans." + var expectedResponse = 'Yes, I have spent some time in New Orleans.'; assert.deepEqual(response, expectedResponse); }); - it.skip('should say if its not been to a location', function() { - var locations = ['Transylvania', 'Washington', 'New Orleans', 'Mystic Falls']; + it('should say if its not been to a location', function () { + var locations = [ + 'Transylvania', + 'Washington', + 'New Orleans', + 'Mystic Falls', + ]; var response = inquirePlace(locations, 'Idaho'); - var expectedResponse = "No, I have never been to Idaho." + var expectedResponse = 'No, I have never been to Idaho.'; assert.deepEqual(response, expectedResponse); }); - it.skip('should be able to find the vampires with bats', function() { + it('should be able to find the vampires with bats', function () { var javi = createVampire('Javi'); var brittany = createVampire('Brittany'); var jeff = createVampire('Jeff', 'fox'); diff --git a/package-lock.json b/package-lock.json index a14533844..a7165814e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,165 +1,214 @@ { "name": "foundations", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "assertion-error": { + "packages": { + "": { + "name": "foundations", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "chai": "^4.2.0", + "mocha": "^5.2.0" + } + }, + "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "engines": { + "node": "*" + } }, - "balanced-match": { + "node_modules/balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, - "brace-expansion": { + "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { + "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, - "browser-stdout": { + "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" }, - "chai": { + "node_modules/chai": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", - "requires": { + "dependencies": { "assertion-error": "^1.1.0", "check-error": "^1.0.2", "deep-eql": "^3.0.1", "get-func-name": "^2.0.0", "pathval": "^1.1.0", "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" } }, - "check-error": { + "node_modules/check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "engines": { + "node": "*" + } }, - "commander": { + "node_modules/commander": { "version": "2.15.1", "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==" }, - "concat-map": { + "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, - "debug": { + "node_modules/debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { + "dependencies": { "ms": "2.0.0" } }, - "deep-eql": { + "node_modules/deep-eql": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "requires": { + "dependencies": { "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=0.12" } }, - "diff": { + "node_modules/diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "engines": { + "node": ">=0.3.1" + } }, - "escape-string-regexp": { + "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "engines": { + "node": ">=0.8.0" + } }, - "fs.realpath": { + "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, - "get-func-name": { + "node_modules/get-func-name": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=" + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "engines": { + "node": "*" + } }, - "glob": { + "node_modules/glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "requires": { + "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" } }, - "growl": { + "node_modules/growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==" + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "engines": { + "node": ">=4.x" + } }, - "has-flag": { + "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "engines": { + "node": ">=4" + } }, - "he": { + "node_modules/he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "bin": { + "he": "bin/he" + } }, - "inflight": { + "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { + "dependencies": { "once": "^1.3.0", "wrappy": "1" } }, - "inherits": { + "node_modules/inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, - "minimatch": { + "node_modules/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "requires": { + "dependencies": { "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" } }, - "minimist": { + "node_modules/minimist": { "version": "0.0.8", "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, - "mkdirp": { + "node_modules/mkdirp": { "version": "0.5.1", "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "requires": { + "deprecated": "Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)", + "dependencies": { "minimist": "0.0.8" + }, + "bin": { + "mkdirp": "bin/cmd.js" } }, - "mocha": { + "node_modules/mocha": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", - "requires": { + "dependencies": { "browser-stdout": "1.3.1", "commander": "2.15.1", "debug": "3.1.0", @@ -171,45 +220,64 @@ "minimatch": "3.0.4", "mkdirp": "0.5.1", "supports-color": "5.4.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha" + }, + "engines": { + "node": ">= 4.0.0" } }, - "ms": { + "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "once": { + "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { + "dependencies": { "wrappy": "1" } }, - "path-is-absolute": { + "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "engines": { + "node": ">=0.10.0" + } }, - "pathval": { + "node_modules/pathval": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=" + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "engines": { + "node": "*" + } }, - "supports-color": { + "node_modules/supports-color": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "requires": { + "dependencies": { "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" } }, - "type-detect": { + "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "engines": { + "node": ">=4" + } }, - "wrappy": { + "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="