クラスAのインスタンスを含むクラスとB、の状態を更新する呼び出し関数fooの関数があります。コード例(Javascript)は次のとおりです。AsetBB
A = function () {
this.init = function (b) {
this.b = b
}
this.foo = function (val) {
this.b.set(val)
}
this.bar = function () {
return this.b.get()
}
}
B = function () {
this.set = function (val) {
this.v = val
}
this.get = function () {
return this.v
}
}
(モックやスタブなどを使用して)実装に依存しないfooようにテストを維持しながら、関数を単体テストするにはどうすればよいですか?AB