Skip to content

Instantly share code, notes, and snippets.

@jtr860830
jtr860830 / cal.step.js
Last active December 13, 2018 03:48
BDD example for medium
// features/step_definitions/cal.step.js
import { Given, When, Then } from "cucumber"
import * as chai from "chai"
chai.should()
Given('the first number is {int}', function (first) {
// Write code here that turns the phrase above into concrete actions
this.first = first
})
@jtr860830
jtr860830 / cal.chinese.feature
Last active December 13, 2018 03:34
BDD example for medium
#language: zh-TW
功能: 計算機
進行加減乘除四則運算
場景: 1 加 2 會等於 3
假設 第一個數字是 1
並且 第二個數字是 2
當 兩者相加
那麼 結果會是 3
@jtr860830
jtr860830 / cal.js
Last active December 13, 2018 03:34
TDD and BDD example for medium
function add(x, y) {
return x + y
}
function minus(x, y) {
return x - y
}
export {
add,
@jtr860830
jtr860830 / cal.test.js
Last active December 13, 2018 03:34
TDD example for medium
import * as assert from 'assert'
describe('add function', function () {
it('add(1, 2) = 3', function () {
assert.deepStrictEqual(add(1, 2), 3)
})
it('add(1, -2) = -1', function () {
assert.deepStrictEqual(add(1, -2), -1)
})