Instantly share code, notes, and snippets.

@bbraithwaite /calculator.js Secret
Last active Dec 28, 2018

Embed
What would you like to do?
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

This comment has been minimized.

micronyks commented Nov 17, 2015

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

@optimized4u

This comment has been minimized.

optimized4u commented Apr 15, 2016

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

@rjgferreira

This comment has been minimized.

rjgferreira commented Jun 18, 2016

Excellent didactic! Thank you for this light!

@nbkhope

This comment has been minimized.

nbkhope commented Aug 8, 2016

Thank you 👍

@Shafiuzzaman-Hira

This comment has been minimized.

Shafiuzzaman-Hira commented Aug 9, 2016

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

@erick2014

This comment has been minimized.

erick2014 commented Sep 7, 2016

awesome tut man!

@kapillohakare123

This comment has been minimized.

kapillohakare123 commented Sep 14, 2016

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

@ancilt26

This comment has been minimized.

ancilt26 commented Oct 10, 2016

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

@aerojeyenth

This comment has been minimized.

aerojeyenth commented Nov 10, 2016

Really Helps. Thanks for this getting started tutorial.

@The-El-Duderino

This comment has been minimized.

The-El-Duderino commented Feb 2, 2017

great tutorial to start with!

@AlayVora

This comment has been minimized.

AlayVora commented Jul 12, 2017

Really helped. keep up the good work

@bennawanda

This comment has been minimized.

bennawanda commented Aug 9, 2017

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

This comment has been minimized.

rehan544 commented Nov 6, 2017

nicely explained ...!

@elyr

This comment has been minimized.

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