Commit 3e00622d44f9500728f74eec65b270765740a7eb
1 parent
51adda62
Exists in
colab
and in
4 other branches
Fixed branch filling JS test
Showing
1 changed file
with
14 additions
and
25 deletions
Show diff stats
spec/javascripts/repository/branch_spec.js.coffee
| ... | ... | @@ -79,42 +79,31 @@ describe "Repository.Branch", -> |
| 79 | 79 | |
| 80 | 80 | describe '#fetch', -> |
| 81 | 81 | beforeEach -> |
| 82 | - @subject.cancel_request = sinon.spy() | |
| 82 | + @subject.cancel_request = sinon.stub() | |
| 83 | 83 | |
| 84 | 84 | context 'with valid address', -> |
| 85 | 85 | beforeEach -> |
| 86 | - @subject.fill_options = sinon.spy() | |
| 87 | -# @subject.names = {'https://github.com/mezuro/prezento.git': ['master', 'dev']} | |
| 86 | + sinon.stub(@subject, "fill_options") | |
| 87 | + | |
| 88 | + afterEach -> | |
| 89 | + @subject.fill_options.restore() | |
| 88 | 90 | |
| 89 | 91 | context 'with new address', -> |
| 90 | 92 | beforeEach -> |
| 91 | 93 | @subject.names = {} |
| 92 | - | |
| 93 | 94 | @address = 'https://github.com/mezuro/kalibro_processor.git' |
| 94 | 95 | |
| 95 | - @select = sinon.stub() | |
| 96 | - # Stub just the selector and not the whole jQuery object | |
| 97 | - find_stub = sinon.stub($, "find") | |
| 98 | - find_stub.withArgs("#repository_branch").returns(@select) | |
| 99 | - find_stub.withArgs("#repository_scm_type").returns({val: -> "SVN"}) | |
| 100 | - | |
| 101 | - @server = sinon.fakeServer.create() | |
| 102 | - @server.respondImmediately = true | |
| 103 | - | |
| 104 | - address_url_encoded = encodeURI(@address) | |
| 105 | - @server.respondWith('GET', '/repository_branches&url=' + address_url_encoded + '&scm_type=' + 'GIT', | |
| 106 | - [200, { "Content-Type": "application/json" }, JSON.stringify({ | |
| 107 | - "branches": ["stable", "dev", "master"] | |
| 108 | - })] | |
| 109 | - ) | |
| 96 | + @select = {empty: sinon.stub()} | |
| 97 | + $ = sinon.stub(window, "$") | |
| 98 | + $.withArgs("#repository_branch").returns(@select) | |
| 99 | + $.withArgs("#repository_scm_type").returns({val: -> "GIT"}) | |
| 100 | + $.get = sinon.stub().withArgs('/repository_branches', {'url': @address, 'scm_type': 'GIT'}).returns().yields({ | |
| 101 | + 'branches': ['stable', 'dev', 'master'] | |
| 102 | + }) | |
| 110 | 103 | |
| 111 | 104 | afterEach -> |
| 112 | - @server.restore() | |
| 113 | - $.find.restore() | |
| 105 | + $.restore() | |
| 114 | 106 | |
| 115 | 107 | it 'should fetch the branches and fill the options', -> |
| 116 | 108 | @subject.fetch(@address) |
| 117 | - @server.respond() | |
| 118 | - console.log(@server.requests[0]) | |
| 119 | - debugger | |
| 120 | - assert.isTrue(@subject.fill_options.calledWith(['stable', 'dev', 'master'], @select)) | |
| 109 | + sinon.assert.calledWith(@subject.fill_options, ['stable', 'dev', 'master'], @select) | ... | ... |