Skip to content
Snippets Groups Projects
Commit 7a2a9bb4 authored by Mike Greiling's avatar Mike Greiling
Browse files

replace Teaspoon fixture methods with jasmine-jquery methods to reduce dependency on Teaspoon

parent 10d483ea
No related branches found
No related tags found
No related merge requests found
Showing
with 50 additions and 51 deletions
Loading
@@ -8,9 +8,9 @@
Loading
@@ -8,9 +8,9 @@
var INVALID_URL = 'http://goesnowhere.nothing/whereami'; var INVALID_URL = 'http://goesnowhere.nothing/whereami';
var $boxClosed, $boxOpen, $btnClose, $btnReopen; var $boxClosed, $boxOpen, $btnClose, $btnReopen;
   
fixture.preload('issues/closed-issue.html.raw'); preloadFixtures('issues/closed-issue.html.raw');
fixture.preload('issues/issue-with-task-list.html.raw'); preloadFixtures('issues/issue-with-task-list.html.raw');
fixture.preload('issues/open-issue.html.raw'); preloadFixtures('issues/open-issue.html.raw');
   
function expectErrorMessage() { function expectErrorMessage() {
var $flashMessage = $('div.flash-alert'); var $flashMessage = $('div.flash-alert');
Loading
@@ -61,8 +61,8 @@
Loading
@@ -61,8 +61,8 @@
   
describe('Issue', function() { describe('Issue', function() {
describe('task lists', function() { describe('task lists', function() {
fixture.load('issues/issue-with-task-list.html.raw');
beforeEach(function() { beforeEach(function() {
loadFixtures('issues/issue-with-task-list.html.raw');
this.issue = new Issue(); this.issue = new Issue();
}); });
   
Loading
@@ -86,7 +86,7 @@
Loading
@@ -86,7 +86,7 @@
   
describe('close issue', function() { describe('close issue', function() {
beforeEach(function() { beforeEach(function() {
fixture.load('issues/open-issue.html.raw'); loadFixtures('issues/open-issue.html.raw');
findElements(); findElements();
this.issue = new Issue(); this.issue = new Issue();
   
Loading
@@ -140,7 +140,7 @@
Loading
@@ -140,7 +140,7 @@
   
describe('reopen issue', function() { describe('reopen issue', function() {
beforeEach(function() { beforeEach(function() {
fixture.load('issues/closed-issue.html.raw'); loadFixtures('issues/closed-issue.html.raw');
findElements(); findElements();
this.issue = new Issue(); this.issue = new Issue();
   
Loading
Loading
Loading
@@ -17,10 +17,10 @@
Loading
@@ -17,10 +17,10 @@
(() => { (() => {
let saveLabelCount = 0; let saveLabelCount = 0;
describe('Issue dropdown sidebar', () => { describe('Issue dropdown sidebar', () => {
fixture.preload('static/issue_sidebar_label.html.raw'); preloadFixtures('static/issue_sidebar_label.html.raw');
   
beforeEach(() => { beforeEach(() => {
fixture.load('static/issue_sidebar_label.html.raw'); loadFixtures('static/issue_sidebar_label.html.raw');
new IssuableContext('{"id":1,"name":"Administrator","username":"root"}'); new IssuableContext('{"id":1,"name":"Administrator","username":"root"}');
new LabelsSelect(); new LabelsSelect();
   
Loading
Loading
Loading
@@ -6,7 +6,7 @@
Loading
@@ -6,7 +6,7 @@
(function() { (function() {
describe('LineHighlighter', function() { describe('LineHighlighter', function() {
var clickLine; var clickLine;
fixture.preload('static/line_highlighter.html.raw'); preloadFixtures('static/line_highlighter.html.raw');
clickLine = function(number, eventData) { clickLine = function(number, eventData) {
var e; var e;
if (eventData == null) { if (eventData == null) {
Loading
@@ -20,7 +20,7 @@
Loading
@@ -20,7 +20,7 @@
} }
}; };
beforeEach(function() { beforeEach(function() {
fixture.load('static/line_highlighter.html.raw'); loadFixtures('static/line_highlighter.html.raw');
this["class"] = new LineHighlighter(); this["class"] = new LineHighlighter();
this.css = this["class"].highlightClass; this.css = this["class"].highlightClass;
return this.spies = { return this.spies = {
Loading
Loading
Loading
@@ -6,9 +6,9 @@
Loading
@@ -6,9 +6,9 @@
(function() { (function() {
describe('MergeRequest', function() { describe('MergeRequest', function() {
return describe('task lists', function() { return describe('task lists', function() {
fixture.preload('static/merge_requests_show.html.raw'); preloadFixtures('static/merge_requests_show.html.raw');
beforeEach(function() { beforeEach(function() {
fixture.load('static/merge_requests_show.html.raw'); loadFixtures('static/merge_requests_show.html.raw');
return this.merge = new MergeRequest(); return this.merge = new MergeRequest();
}); });
it('modifies the Markdown field', function() { it('modifies the Markdown field', function() {
Loading
Loading
Loading
@@ -16,7 +16,7 @@
Loading
@@ -16,7 +16,7 @@
}; };
$.extend(stubLocation, defaults, stubs || {}); $.extend(stubLocation, defaults, stubs || {});
}; };
fixture.preload('static/merge_request_tabs.html.raw'); preloadFixtures('static/merge_request_tabs.html.raw');
   
beforeEach(function () { beforeEach(function () {
this.class = new gl.MergeRequestTabs({ stubLocation: stubLocation }); this.class = new gl.MergeRequestTabs({ stubLocation: stubLocation });
Loading
@@ -30,7 +30,7 @@
Loading
@@ -30,7 +30,7 @@
describe('#activateTab', function () { describe('#activateTab', function () {
beforeEach(function () { beforeEach(function () {
spyOn($, 'ajax').and.callFake(function () {}); spyOn($, 'ajax').and.callFake(function () {});
fixture.load('static/merge_request_tabs.html.raw'); loadFixtures('static/merge_request_tabs.html.raw');
this.subject = this.class.activateTab; this.subject = this.class.activateTab;
}); });
it('shows the first tab when action is show', function () { it('shows the first tab when action is show', function () {
Loading
Loading
Loading
@@ -5,10 +5,10 @@
Loading
@@ -5,10 +5,10 @@
   
(() => { (() => {
describe('Mini Pipeline Graph Dropdown', () => { describe('Mini Pipeline Graph Dropdown', () => {
fixture.preload('static/mini_dropdown_graph.html.raw'); preloadFixtures('static/mini_dropdown_graph.html.raw');
   
beforeEach(() => { beforeEach(() => {
fixture.load('static/mini_dropdown_graph.html.raw'); loadFixtures('static/mini_dropdown_graph.html.raw');
}); });
   
describe('When is initialized', () => { describe('When is initialized', () => {
Loading
Loading
Loading
@@ -8,7 +8,7 @@
Loading
@@ -8,7 +8,7 @@
describe('Branch', function() { describe('Branch', function() {
return describe('create a new branch', function() { return describe('create a new branch', function() {
var expectToHaveError, fillNameWith; var expectToHaveError, fillNameWith;
fixture.preload('static/new_branch.html.raw'); preloadFixtures('static/new_branch.html.raw');
fillNameWith = function(value) { fillNameWith = function(value) {
return $('.js-branch-name').val(value).trigger('blur'); return $('.js-branch-name').val(value).trigger('blur');
}; };
Loading
@@ -16,7 +16,7 @@
Loading
@@ -16,7 +16,7 @@
return expect($('.js-branch-name-error span').text()).toEqual(error); return expect($('.js-branch-name-error span').text()).toEqual(error);
}; };
beforeEach(function() { beforeEach(function() {
fixture.load('static/new_branch.html.raw'); loadFixtures('static/new_branch.html.raw');
$('form').on('submit', function(e) { $('form').on('submit', function(e) {
return e.preventDefault(); return e.preventDefault();
}); });
Loading
Loading
Loading
@@ -13,10 +13,10 @@
Loading
@@ -13,10 +13,10 @@
   
describe('Notes', function() { describe('Notes', function() {
var commentsTemplate = 'issues/issue_with_comment.html.raw'; var commentsTemplate = 'issues/issue_with_comment.html.raw';
fixture.preload(commentsTemplate); preloadFixtures(commentsTemplate);
   
beforeEach(function () { beforeEach(function () {
fixture.load(commentsTemplate); loadFixtures(commentsTemplate);
gl.utils.disableButtonIfEmptyField = _.noop; gl.utils.disableButtonIfEmptyField = _.noop;
window.project_uploads_path = 'http://test.host/uploads'; window.project_uploads_path = 'http://test.host/uploads';
}); });
Loading
Loading
Loading
@@ -2,10 +2,10 @@
Loading
@@ -2,10 +2,10 @@
   
(() => { (() => {
describe('Pipelines', () => { describe('Pipelines', () => {
fixture.preload('static/pipeline_graph.html.raw'); preloadFixtures('static/pipeline_graph.html.raw');
   
beforeEach(() => { beforeEach(() => {
fixture.load('static/pipeline_graph.html.raw'); loadFixtures('static/pipeline_graph.html.raw');
}); });
   
it('should be defined', () => { it('should be defined', () => {
Loading
Loading
Loading
@@ -16,10 +16,9 @@
Loading
@@ -16,10 +16,9 @@
window.gon.api_version = 'v3'; window.gon.api_version = 'v3';
   
describe('Project Title', function() { describe('Project Title', function() {
fixture.preload('static/project_title.html.raw'); preloadFixtures('static/project_title.html.raw');
fixture.preload('projects.json');
beforeEach(function() { beforeEach(function() {
fixture.load('static/project_title.html.raw'); loadFixtures('static/project_title.html.raw');
return this.project = new Project(); return this.project = new Project();
}); });
return describe('project list', function() { return describe('project list', function() {
Loading
@@ -34,7 +33,7 @@
Loading
@@ -34,7 +33,7 @@
   
beforeEach((function(_this) { beforeEach((function(_this) {
return function() { return function() {
_this.projects_data = fixture.load('projects.json')[0]; _this.projects_data = getJSONFixture('projects.json');
return spyOn(jQuery, 'ajax').and.callFake(fakeAjaxResponse.bind(_this)); return spyOn(jQuery, 'ajax').and.callFake(fakeAjaxResponse.bind(_this));
}; };
})(this)); })(this));
Loading
Loading
Loading
@@ -36,9 +36,9 @@
Loading
@@ -36,9 +36,9 @@
   
describe('RightSidebar', function() { describe('RightSidebar', function() {
var fixtureName = 'issues/open-issue.html.raw'; var fixtureName = 'issues/open-issue.html.raw';
fixture.preload(fixtureName); preloadFixtures(fixtureName);
beforeEach(function() { beforeEach(function() {
fixture.load(fixtureName); loadFixtures(fixtureName);
this.sidebar = new Sidebar; this.sidebar = new Sidebar;
$aside = $('.right-sidebar'); $aside = $('.right-sidebar');
$page = $('.page-with-sidebar'); $page = $('.page-with-sidebar');
Loading
@@ -67,7 +67,7 @@
Loading
@@ -67,7 +67,7 @@
it('should broadcast todo:toggle event when add todo clicked', function() { it('should broadcast todo:toggle event when add todo clicked', function() {
spyOn(jQuery, 'ajax').and.callFake(function() { spyOn(jQuery, 'ajax').and.callFake(function() {
var d = $.Deferred(); var d = $.Deferred();
var response = fixture.load('todos.json'); var response = getJSONFixture('todos.json');
d.resolve(response); d.resolve(response);
return d.promise(); return d.promise();
}); });
Loading
Loading
Loading
@@ -112,9 +112,9 @@
Loading
@@ -112,9 +112,9 @@
}; };
   
describe('Search autocomplete dropdown', function() { describe('Search autocomplete dropdown', function() {
fixture.preload('static/search_autocomplete.html.raw'); preloadFixtures('static/search_autocomplete.html.raw');
beforeEach(function() { beforeEach(function() {
fixture.load('static/search_autocomplete.html.raw'); loadFixtures('static/search_autocomplete.html.raw');
return widget = new gl.SearchAutocomplete; return widget = new gl.SearchAutocomplete;
}); });
it('should show Dashboard specific dropdown menu', function() { it('should show Dashboard specific dropdown menu', function() {
Loading
Loading
Loading
@@ -6,9 +6,9 @@
Loading
@@ -6,9 +6,9 @@
(function() { (function() {
describe('ShortcutsIssuable', function() { describe('ShortcutsIssuable', function() {
var fixtureName = 'issues/open-issue.html.raw'; var fixtureName = 'issues/open-issue.html.raw';
fixture.preload(fixtureName); preloadFixtures(fixtureName);
beforeEach(function() { beforeEach(function() {
fixture.load(fixtureName); loadFixtures(fixtureName);
document.querySelector('.js-new-note-form').classList.add('js-main-target-form'); document.querySelector('.js-new-note-form').classList.add('js-main-target-form');
return this.shortcut = new ShortcutsIssuable(); return this.shortcut = new ShortcutsIssuable();
}); });
Loading
Loading
Loading
@@ -15,10 +15,10 @@
Loading
@@ -15,10 +15,10 @@
return memo; return memo;
} }
   
fixture.preload(fixtureTemplate); preloadFixtures(fixtureTemplate);
   
beforeEach(() => { beforeEach(() => {
fixture.load(fixtureTemplate); loadFixtures(fixtureTemplate);
}); });
   
it('does nothing if no tab was previously selected', () => { it('does nothing if no tab was previously selected', () => {
Loading
Loading
Loading
@@ -103,7 +103,7 @@
Loading
@@ -103,7 +103,7 @@
describe('DOM Events', function () { describe('DOM Events', function () {
beforeEach(function () { beforeEach(function () {
// This ensures DOM and DOM events are initialized for these specs. // This ensures DOM and DOM events are initialized for these specs.
fixture.set('<div></div>'); setFixtures('<div></div>');
   
this.smartInterval = createDefaultSmartInterval(); this.smartInterval = createDefaultSmartInterval();
}); });
Loading
Loading
Loading
@@ -37,12 +37,12 @@
Loading
@@ -37,12 +37,12 @@
// file as a manifest. // file as a manifest.
// For more information: http://github.com/modeset/teaspoon // For more information: http://github.com/modeset/teaspoon
   
(function() { // set our fixtures path
jasmine.getFixtures().fixturesPath = '/teaspoon/fixtures';
jasmine.getJSONFixtures().fixturesPath = '/teaspoon/fixtures';
}).call(this);
   
// defined in ActionDispatch::TestRequest // defined in ActionDispatch::TestRequest
// see https://github.com/rails/rails/blob/v4.2.7.1/actionpack/lib/action_dispatch/testing/test_request.rb#L7 // see https://github.com/rails/rails/blob/v4.2.7.1/actionpack/lib/action_dispatch/testing/test_request.rb#L7
window.gl = window.gl || {}; window.gl = window.gl || {};
gl.TEST_HOST = 'http://test.host'; window.gl.TEST_HOST = 'http://test.host';
window.gon = window.gon || {};
Loading
@@ -13,7 +13,7 @@
Loading
@@ -13,7 +13,7 @@
}; };
describe('on a js-syntax-highlight element', function() { describe('on a js-syntax-highlight element', function() {
beforeEach(function() { beforeEach(function() {
return fixture.set('<div class="js-syntax-highlight"></div>'); return setFixtures('<div class="js-syntax-highlight"></div>');
}); });
return it('applies syntax highlighting', function() { return it('applies syntax highlighting', function() {
stubUserColorScheme('monokai'); stubUserColorScheme('monokai');
Loading
@@ -23,7 +23,7 @@
Loading
@@ -23,7 +23,7 @@
}); });
return describe('on a parent element', function() { return describe('on a parent element', function() {
beforeEach(function() { beforeEach(function() {
return fixture.set("<div class=\"parent\">\n <div class=\"js-syntax-highlight\"></div>\n <div class=\"foo\"></div>\n <div class=\"js-syntax-highlight\"></div>\n</div>"); return setFixtures("<div class=\"parent\">\n <div class=\"js-syntax-highlight\"></div>\n <div class=\"foo\"></div>\n <div class=\"js-syntax-highlight\"></div>\n</div>");
}); });
it('applies highlighting to all applicable children', function() { it('applies highlighting to all applicable children', function() {
stubUserColorScheme('monokai'); stubUserColorScheme('monokai');
Loading
@@ -33,7 +33,7 @@
Loading
@@ -33,7 +33,7 @@
}); });
return it('prevents an infinite loop when no matches exist', function() { return it('prevents an infinite loop when no matches exist', function() {
var highlight; var highlight;
fixture.set('<div></div>'); setFixtures('<div></div>');
highlight = function() { highlight = function() {
return $('div').syntaxHighlight(); return $('div').syntaxHighlight();
}; };
Loading
Loading
Loading
@@ -10,10 +10,10 @@
Loading
@@ -10,10 +10,10 @@
   
(function() { (function() {
describe('U2FAuthenticate', function() { describe('U2FAuthenticate', function() {
fixture.preload('u2f/authenticate.html.raw'); preloadFixtures('u2f/authenticate.html.raw');
   
beforeEach(function() { beforeEach(function() {
fixture.load('u2f/authenticate.html.raw'); loadFixtures('u2f/authenticate.html.raw');
this.u2fDevice = new MockU2FDevice; this.u2fDevice = new MockU2FDevice;
this.container = $("#js-authenticate-u2f"); this.container = $("#js-authenticate-u2f");
this.component = new window.gl.U2FAuthenticate( this.component = new window.gl.U2FAuthenticate(
Loading
Loading
Loading
@@ -10,10 +10,10 @@
Loading
@@ -10,10 +10,10 @@
   
(function() { (function() {
describe('U2FRegister', function() { describe('U2FRegister', function() {
fixture.preload('u2f/register.html.raw'); preloadFixtures('u2f/register.html.raw');
   
beforeEach(function() { beforeEach(function() {
fixture.load('u2f/register.html.raw'); loadFixtures('u2f/register.html.raw');
this.u2fDevice = new MockU2FDevice; this.u2fDevice = new MockU2FDevice;
this.container = $("#js-register-u2f"); this.container = $("#js-register-u2f");
this.component = new U2FRegister(this.container, $("#js-register-u2f-templates"), {}, "token"); this.component = new U2FRegister(this.container, $("#js-register-u2f-templates"), {}, "token");
Loading
Loading
Loading
@@ -5,7 +5,7 @@ describe('Commit component', () => {
Loading
@@ -5,7 +5,7 @@ describe('Commit component', () => {
let component; let component;
   
it('should render a code-fork icon if it does not represent a tag', () => { it('should render a code-fork icon if it does not represent a tag', () => {
fixture.set('<div class="test-commit-container"></div>'); setFixtures('<div class="test-commit-container"></div>');
component = new window.gl.CommitComponent({ component = new window.gl.CommitComponent({
el: document.querySelector('.test-commit-container'), el: document.querySelector('.test-commit-container'),
propsData: { propsData: {
Loading
@@ -30,7 +30,7 @@ describe('Commit component', () => {
Loading
@@ -30,7 +30,7 @@ describe('Commit component', () => {
   
describe('Given all the props', () => { describe('Given all the props', () => {
beforeEach(() => { beforeEach(() => {
fixture.set('<div class="test-commit-container"></div>'); setFixtures('<div class="test-commit-container"></div>');
   
props = { props = {
tag: true, tag: true,
Loading
@@ -105,7 +105,7 @@ describe('Commit component', () => {
Loading
@@ -105,7 +105,7 @@ describe('Commit component', () => {
   
describe('When commit title is not provided', () => { describe('When commit title is not provided', () => {
it('should render default message', () => { it('should render default message', () => {
fixture.set('<div class="test-commit-container"></div>'); setFixtures('<div class="test-commit-container"></div>');
props = { props = {
tag: false, tag: false,
commitRef: { commitRef: {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment