Skip to content

Commit 80ffcc0

Browse files
committed
필요없는 tc 제거
1 parent b81d54e commit 80ffcc0

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

ClickCounter/ClickCountView.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
var ClickCountView = function(clickCounter, options) {
22
var view = {
3-
getClickCount() {
4-
return clickCounter.getCounter()
5-
},
6-
73
increseAndUpdateView() {
84
clickCounter.increase()
9-
this.updateView()
5+
view.updateView()
106
},
117

128
updateView() {
13-
options.updateEl.text(this.getClickCount())
9+
options.updateEl.text(clickCounter.getCounter())
1410
}
1511
}
1612

ClickCounter/ClickCountView.spec.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ describe('ClickCountView 모듈', () => {
44
beforeEach(() => {
55
updateEl = $('<span></span>');
66
triggerEl = $('<button></button>');
7-
clickCounter = ClickCounter();
7+
clickCounter = ClickCounter(); // todo: spy로 하자
88
view = ClickCountView(clickCounter, { updateEl, triggerEl })
99
})
1010

11-
it('클릭 이벤트가 발생하면 increseAndUpdateView를 실행한다', ()=> {
12-
spyOn(view, 'increseAndUpdateView')
13-
triggerEl.trigger('click')
14-
expect(view.increseAndUpdateView).toHaveBeenCalled()
11+
describe('updateView()', () => {
12+
it('ClickCounter의 getCounter() 실행결과를 출력한다', ()=> {
13+
const counterValue = clickCounter.getCounter().toString()
14+
view.updateView()
15+
expect(updateEl.text()).toBe(counterValue)
16+
})
1517
})
1618

1719
describe('increseAndUpdateView()', () => {
@@ -26,17 +28,11 @@ describe('ClickCountView 모듈', () => {
2628
view.increseAndUpdateView()
2729
expect(view.updateView).toHaveBeenCalled()
2830
})
29-
30-
it('updateEl의 텍스트를 설정한다', () => {
31-
view.increseAndUpdateView()
32-
expect(updateEl.text()).toBe(view.getClickCount().toString())
33-
})
3431
})
3532

36-
describe('updateView()', () => {
37-
it('클릭한적이 없으면 "0"을 출력한다', ()=> {
38-
view.updateView()
39-
expect(updateEl.text()).toBe('0')
40-
})
33+
it('클릭 이벤트가 발생하면 increseAndUpdateView를 실행한다', ()=> {
34+
spyOn(view, 'increseAndUpdateView')
35+
triggerEl.trigger('click')
36+
expect(view.increseAndUpdateView).toHaveBeenCalled()
4137
})
4238
})

0 commit comments

Comments
 (0)