Skip to content

Instantly share code, notes, and snippets.

@bbraithwaite
Last active December 28, 2018 16:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save bbraithwaite/376bb62af8b003b94fdc to your computer and use it in GitHub Desktop.
Save bbraithwaite/376bb62af8b003b94fdc to your computer and use it in GitHub Desktop.
var calculator = {
sum: function (x, y) {
return x + y;
},
subtract: function (x, y) {
return x - y;
},
divide: function (x, y) {
return (y === 0) ? 0 : x / y;
}
}
describe('calculator', function () {
describe('sum', function () {
it('1 + 1 should equal 2', function () {
expect(calculator.sum(1, 1)).toBe(2);
});
});
describe('subtract', function () {
it('3 - 2 should equal 1', function () {
expect(calculator.subtract(3, 2)).toBe(1);
});
});
describe('divide', function () {
it('10 / 5 should equal 2', function () {
expect(calculator.divide(10, 5)).toBe(2);
});
it('zero divisor should equal 0', function () {
expect(calculator.divide(10, 0)).toBe(0);
});
});
});
@micronyks
Copy link

Thanks for you tutorial. At least and last came to know how exactly it works !

@optimized4u
Copy link

Thank you for great starting tutorial, now on to the next.

@rjgferreira
Copy link

Excellent didactic! Thank you for this light!

@nbkhope
Copy link

nbkhope commented Aug 8, 2016

Thank you 👍

@shafiuzzaman-md
Copy link

Thanks a lot. This was really helpful to start the journey.

@erick2014
Copy link

awesome tut man!

@kapillohakare123
Copy link

Thank you for this introductory tutorial. Helped a lot for me.

@ancilt26
Copy link

Such an awesome tutorial dude, really concise and everything! Thanks heaps! :)

@aerojeyenth
Copy link

Really Helps. Thanks for this getting started tutorial.

@The-El-Duderino
Copy link

great tutorial to start with!

@AlayVora
Copy link

Really helped. keep up the good work

@bennawanda
Copy link

Could someone tell me how to test this block? In typescript and angular 2. In short, I would like to know how to access and set a function's local variables like in this case.

  test(): any {
    var value = 2;
    if(value === 2){
      return true;
    }else{
      return false;
    }
  }

@rehan544
Copy link

rehan544 commented Nov 6, 2017

nicely explained ...!

@elyr
Copy link

elyr commented Dec 28, 2018

thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment