Skip to content

Instantly share code, notes, and snippets.

@mlevkovsky
Last active February 25, 2020 01:06
Show Gist options
  • Save mlevkovsky/7067ed036eb9854cc7f039a886209b50 to your computer and use it in GitHub Desktop.
Save mlevkovsky/7067ed036eb9854cc7f039a886209b50 to your computer and use it in GitHub Desktop.
export class Calculator {
public add(firstAddend: number, secondAddend: number): number {
return firstAddend + secondAddend;
}
public subtract(minuend: number, subtrahend: number): number {
return minuend - subtrahend;
}
public multiply(firstFactor: number, secondFactor: number): number {
return firstFactor * secondFactor;
}
}
describe('Calculator', () => {
it('sums up two numbers properly', () => {
calculator = new Calculator();
expect(calculator.add(2,2)).to.equal(4);
});
// ✅test passes, bug is fixed, PM and stakeholders celebrate your genius
it('subtracts two numbers properly', () => {
calculator = new Calculator();
expect(calculator.subtract(4,2)).to.equal(2);
expect(calculator.subtract(10,3)).to.equal(7);
expect(calculator.subtract(-4,2)).to.equal(-6);
expect(calculator.subtract(-4,-2)).to.equal(-2);
});
it('multiplies two numbers properly', () => {
calculator = new Calculator();
expect(calculator.subtract(2,2)).to.equal(4);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment