diff options
Diffstat (limited to 'spec/javascripts/api_spec.js')
-rw-r--r-- | spec/javascripts/api_spec.js | 64 |
1 files changed, 19 insertions, 45 deletions
diff --git a/spec/javascripts/api_spec.js b/spec/javascripts/api_spec.js index 54cb6d84109..091edf13cfe 100644 --- a/spec/javascripts/api_spec.js +++ b/spec/javascripts/api_spec.js @@ -250,71 +250,45 @@ describe('Api', () => { }); }); - describe('licenseText', () => { - it('fetches a license text', done => { - const licenseKey = "driver's license"; - const data = { unused: 'option' }; - const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/templates/licenses/${licenseKey}`; + describe('issueTemplate', () => { + it('fetches an issue template', done => { + const namespace = 'some namespace'; + const project = 'some project'; + const templateKey = ' template #%?.key '; + const templateType = 'template type'; + const expectedUrl = `${dummyUrlRoot}/${namespace}/${project}/templates/${templateType}/${encodeURIComponent( + templateKey, + )}`; mock.onGet(expectedUrl).reply(200, 'test'); - Api.licenseText(licenseKey, data, response => { + Api.issueTemplate(namespace, project, templateKey, templateType, (error, response) => { expect(response).toBe('test'); done(); }); }); }); - describe('gitignoreText', () => { - it('fetches a gitignore text', done => { - const gitignoreKey = 'ignore git'; - const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/templates/gitignores/${gitignoreKey}`; - mock.onGet(expectedUrl).reply(200, 'test'); - - Api.gitignoreText(gitignoreKey, response => { - expect(response).toBe('test'); - done(); - }); - }); - }); + describe('projectTemplates', () => { + it('fetches a list of templates', done => { + const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/gitlab-org%2Fgitlab-ce/templates/licenses`; - describe('gitlabCiYml', () => { - it('fetches a .gitlab-ci.yml', done => { - const gitlabCiYmlKey = 'Y CI ML'; - const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/templates/gitlab_ci_ymls/${gitlabCiYmlKey}`; mock.onGet(expectedUrl).reply(200, 'test'); - Api.gitlabCiYml(gitlabCiYmlKey, response => { + Api.projectTemplates('gitlab-org/gitlab-ce', 'licenses', {}, response => { expect(response).toBe('test'); done(); }); }); }); - describe('dockerfileYml', () => { - it('fetches a Dockerfile', done => { - const dockerfileYmlKey = 'a giant whale'; - const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/templates/dockerfiles/${dockerfileYmlKey}`; - mock.onGet(expectedUrl).reply(200, 'test'); - - Api.dockerfileYml(dockerfileYmlKey, response => { - expect(response).toBe('test'); - done(); - }); - }); - }); + describe('projectTemplate', () => { + it('fetches a single template', done => { + const data = { unused: 'option' }; + const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/gitlab-org%2Fgitlab-ce/templates/licenses/test%20license`; - describe('issueTemplate', () => { - it('fetches an issue template', done => { - const namespace = 'some namespace'; - const project = 'some project'; - const templateKey = ' template #%?.key '; - const templateType = 'template type'; - const expectedUrl = `${dummyUrlRoot}/${namespace}/${project}/templates/${templateType}/${encodeURIComponent( - templateKey, - )}`; mock.onGet(expectedUrl).reply(200, 'test'); - Api.issueTemplate(namespace, project, templateKey, templateType, (error, response) => { + Api.projectTemplate('gitlab-org/gitlab-ce', 'licenses', 'test license', data, response => { expect(response).toBe('test'); done(); }); |