From 5c483fd8656805b39b451fcd25c1efbd112d3cae Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 27 Jun 2018 10:43:26 +0100 Subject: specs --- spec/javascripts/api_spec.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'spec/javascripts/api_spec.js') diff --git a/spec/javascripts/api_spec.js b/spec/javascripts/api_spec.js index e8435116221..c53b6da4b48 100644 --- a/spec/javascripts/api_spec.js +++ b/spec/javascripts/api_spec.js @@ -362,4 +362,29 @@ describe('Api', () => { .catch(done.fail); }); }); + + describe('createBranch', () => { + it('creates new branch', done => { + const ref = 'master'; + const branch = 'new-branch-name'; + const dummyProjectPath = 'gitlab-org/gitlab-ce'; + const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/${encodeURIComponent( + dummyProjectPath, + )}/repository/branches`; + + spyOn(axios, 'post').and.callThrough(); + + mock.onPost(expectedUrl).replyOnce(200, { + name: branch, + }); + + Api.createBranch(dummyProjectPath, { ref, branch }) + .then(({ data }) => { + expect(data.name).toBe(branch); + expect(axios.post).toHaveBeenCalledWith(expectedUrl, { ref, branch }); + }) + .then(done) + .catch(done.fail); + }); + }); }); -- cgit v1.2.1