gitlab-org--gitlab-foss/spec/javascripts/syntax_highlight_spec.js
Mike Greiling 69e4072f89 Merge branch 'master' into go-go-gadget-webpack
* master: (389 commits)
  Document "No gems fetched from git repositories" policy [ci skip]
  Typos
  Small gramatical tweaks
  Typos
  Added PHP & NPM doc
  Use `:empty_project` where possible in request specs
  Add caching of droplab ajax requests
  Use `:empty_project` where possible in model specs
  Revert 3f17f29a
  Remove unused js response from refs controller
  Add MR id to changelog entry
  fixed small mini pipeline graph line glitch
  Prevent form to be submitted twice
  Fix Error 500 when repositories contain annotated tags pointing to blobs
  Fix /explore sorting (trending)
  Simplify wording in "adding an image" docs
  Remove "official merge window" from CONTRIBUTING.md [ci skip]
  Update repository check documentation
  Fixed flexbox and wrap issues
  Update two_factor_authentication.md
  ...
2017-01-27 19:33:58 -06:00

44 lines
1.6 KiB
JavaScript

/* eslint-disable space-before-function-paren, no-var, no-return-assign, quotes */
require('~/syntax_highlight');
(function() {
describe('Syntax Highlighter', function() {
var stubUserColorScheme;
stubUserColorScheme = function(value) {
if (window.gon == null) {
window.gon = {};
}
return window.gon.user_color_scheme = value;
};
describe('on a js-syntax-highlight element', function() {
beforeEach(function() {
return setFixtures('<div class="js-syntax-highlight"></div>');
});
return it('applies syntax highlighting', function() {
stubUserColorScheme('monokai');
$('.js-syntax-highlight').syntaxHighlight();
return expect($('.js-syntax-highlight')).toHaveClass('monokai');
});
});
return describe('on a parent element', function() {
beforeEach(function() {
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() {
stubUserColorScheme('monokai');
$('.parent').syntaxHighlight();
expect($('.parent, .foo')).not.toHaveClass('monokai');
return expect($('.monokai').length).toBe(2);
});
return it('prevents an infinite loop when no matches exist', function() {
var highlight;
setFixtures('<div></div>');
highlight = function() {
return $('div').syntaxHighlight();
};
return expect(highlight).not.toThrow();
});
});
});
}).call(this);