From bc3f33f92a16d3afdb8a472f60940e7c46a31564 Mon Sep 17 00:00:00 2001 From: Fatih Acet Date: Fri, 22 Jul 2016 17:01:57 +0300 Subject: JSify all the things! --- spec/javascripts/syntax_highlight_spec.js | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 spec/javascripts/syntax_highlight_spec.js (limited to 'spec/javascripts/syntax_highlight_spec.js') diff --git a/spec/javascripts/syntax_highlight_spec.js b/spec/javascripts/syntax_highlight_spec.js new file mode 100644 index 00000000000..89d9e467d73 --- /dev/null +++ b/spec/javascripts/syntax_highlight_spec.js @@ -0,0 +1,40 @@ + +/*= require syntax_highlight */ +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 fixture.set('
'); + }); + 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 fixture.set("
\n
\n
\n
\n
"); + }); + 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; + fixture.set('
'); + highlight = function() { + return $('div').syntaxHighlight(); + }; + return expect(highlight).not.toThrow(); + }); + }); +}); -- cgit v1.2.1