Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
11040589
Commit
11040589
authored
Dec 20, 2016
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds tests for the MiniPipelineGraph class
parent
51353a6b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
2 deletions
+63
-2
app/assets/javascripts/mini_pipeline_graph_dropdown.js.es6
app/assets/javascripts/mini_pipeline_graph_dropdown.js.es6
+4
-2
spec/javascripts/fixtures/mini_dropdown_graph.html.haml
spec/javascripts/fixtures/mini_dropdown_graph.html.haml
+8
-0
spec/javascripts/mini_pipeline_graph_dropdown_spec.js.es6
spec/javascripts/mini_pipeline_graph_dropdown_spec.js.es6
+51
-0
No files found.
app/assets/javascripts/mini_pipeline_graph_dropdown.js.es6
View file @
11040589
...
@@ -16,8 +16,8 @@
...
@@ -16,8 +16,8 @@
*/
*/
(() => {
(() => {
class MiniPipelineGraph {
class MiniPipelineGraph {
constructor(
{ container
}) {
constructor(
opts = {
}) {
this.container =
container
;
this.container =
opts.container || ''
;
this.dropdownListSelector = '.js-builds-dropdown-container';
this.dropdownListSelector = '.js-builds-dropdown-container';
this.getBuildsList = this.getBuildsList.bind(this);
this.getBuildsList = this.getBuildsList.bind(this);
...
@@ -57,6 +57,8 @@
...
@@ -57,6 +57,8 @@
getBuildsList(e) {
getBuildsList(e) {
const endpoint = e.currentTarget.dataset.stageEndpoint;
const endpoint = e.currentTarget.dataset.stageEndpoint;
console.log('ENDPOINT', endpoint);
return $.ajax({
return $.ajax({
dataType: 'json',
dataType: 'json',
type: 'GET',
type: 'GET',
...
...
spec/javascripts/fixtures/mini_dropdown_graph.html.haml
0 → 100644
View file @
11040589
%div
.js-builds-dropdown-tests
%button
.dropdown.js-builds-dropdown-button
{
'data-stage-endpoint'
=>
'foobar'
}
Dropdown
%div
.js-builds-dropdown-container
%div
.js-builds-dropdown-list
%div
.js-builds-dropdown-loading.builds-dropdown-loading.hidden
%span
.fa.fa-spinner.fa-spin
spec/javascripts/mini_pipeline_graph_dropdown_spec.js.es6
0 → 100644
View file @
11040589
/* eslint-disable no-new */
//= require flash
//= require mini_pipeline_graph_dropdown
(() => {
describe('Mini Pipeline Graph Dropdown', () => {
fixture.preload('mini_dropdown_graph');
beforeEach(() => {
fixture.load('mini_dropdown_graph');
});
describe('When is initialized', () => {
it('should initialize without errors when no options are given', () => {
const miniPipelineGraph = new window.gl.MiniPipelineGraph();
expect(miniPipelineGraph.dropdownListSelector).toEqual('.js-builds-dropdown-container');
});
it('should set the container as the given prop', () => {
const container = '.foo';
const miniPipelineGraph = new window.gl.MiniPipelineGraph({ container });
expect(miniPipelineGraph.container).toEqual(container);
});
});
describe('When dropdown is clicked', () => {
it('should call getBuildsList', () => {
const getBuildsListSpy = spyOn(gl.MiniPipelineGraph.prototype, 'getBuildsList').and.callFake(function () {});
new gl.MiniPipelineGraph({ container: '.js-builds-dropdown-tests' });
document.querySelector('.js-builds-dropdown-button').click();
expect(getBuildsListSpy).toHaveBeenCalled();
});
it('should make a request to the endpoint provided in the html', () => {
const ajaxSpy = spyOn($, 'ajax').and.callFake(function () {});
new gl.MiniPipelineGraph({ container: '.js-builds-dropdown-tests' });
document.querySelector('.js-builds-dropdown-button').click();
expect(ajaxSpy.calls.allArgs()[0][0].url).toEqual('foobar');
});
});
});
})();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment