Skip to content

Instantly share code, notes, and snippets.

@Hochul822
Created August 6, 2015 07:50
Show Gist options
  • Save Hochul822/6badfce8d3d862918f01 to your computer and use it in GitHub Desktop.
Save Hochul822/6badfce8d3d862918f01 to your computer and use it in GitHub Desktop.
// Mocha BDD Interface
// describe 함수는 given, when을 나타내는데 쓰이고
// context 함수는 Scenario를 표현하는 데 쓰인다.
// it 함수는 then, User story의 결론을 보여준다.
var assert = require('assert');
var totalDeposit = 0;
function Account(deposit){
totalDeposit = deposit;
};
Account.prototype.getAccount= function(){
return totalDeposit;
};
function Atm(money){
this.money = money;
totalDeposit-= money;
};
Atm.prototype.remainingCash = function(){
return this.money;
};
var account = new Account(5000);
var atm = new Atm(500);
// ATM에서 현금을 인출할 때
describe('Feature: get cash from an ATM:', function() {
context('Scenario: success', function() { // Scenario : 현금인출 성공한 상황
describe('When the user asks the ATM for 500', function() { // When : 유저가 ATM에서 500을 꺼내려할 때
it('Then the ATM will have 500', function() { // Then : ATM은 500을 갖게 된다.
assert.equal( atm.remainingCash() , 500);
});
it("Then the user's account will have 4500", function(done) { // Then : 유저의 계좌에는 4500이 남게 된다.
assert.equal( account.getAccount(), 4500);
done();
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment