Giter Site home page Giter Site logo

intro-to-js-and-jasmine-v-000's Introduction

Intro to Jasmine and JavaScript

Objectives

  • Run Jasmine Tests
  • Read Jasmine Tests
  • Use Debugger to figure out bugs in code

Jasmine

In Jasmine, to make a set of tests for a particular subject you set it apart by creating a describe function with the first argument as the subject, and the second as an anonymous function. In the block of that anonymous function you can either go more specific with nested describe blocks or an it function. It the actual test; it takes a string as the first argument about what it is testing and an anonymous function that contains an expect function that compares your code to the expected outcome.

Test Walk-Through

describe('#favIceCream', function() {
  it('should return your fav icecream', function() {
    expect(favIceCream("mint chocolate chip")).toBe("I love mint chocolate chip");
  });

});

The test above, is testing a function #favIcecream. The it block declares in plain English the expectation being tested. In this case, we're testing that the function returns the favorite icecream. The expect block calls the function behind tests, and uses a matcher (in this case toBe) to test what the return value of the function should be.

The expect is calling the function favIceCream and passing in the parameter "mint chocolate chip".

Instructions

This lab is designed to get you comfortable with the syntax of Jasmine as well as JavaScript. All you need to do to complete it is make all the tests pass in the spec/intro-spec.js. You'll be coding your solution in code.js.

Before you get started, make sure you run learn -b to see the tests output in the browser. Take each test step by step, and remember that you can use debugger if you get stuck.

  1. Write a function called favIceCream, which accepts a parameter and returns the string "I love <NAME_OF_ICECREAM>".

  2. Write a function called shouting, which accepts a string as a parameter and returns the string in all caps.

  3. Write a function called roundDown, which accepts a number as parameter and returns the number rounded down the closest whole number.

  4. Write a function called theTruth, which returns true.

Resources

View Intro to Jasmine and JavaScript on Learn.co and start learning to code for free.

View JS and Jasmine Testing Lab on Learn.co and start learning to code for free.

intro-to-js-and-jasmine-v-000's People

Contributors

annjohn avatar asialindsay avatar deniznida avatar fislabstest avatar franknowinski avatar fs-lms-test-bot avatar joshuabamboo avatar sarogers avatar smulligan85 avatar talum avatar tsiege avatar victhevenot avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.