Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-07-24 23:45:11 +0300
committerFatih Acet <acetfatih@gmail.com>2016-07-24 23:45:11 +0300
commitaaa9509d120524573085e94af9de5cdde83e3271 (patch)
tree3824cffd4cdd132ee9cf75a00a7624f5ccc0dabd /spec/javascripts/syntax_highlight_spec.js
parent56b79181adc0bd6e9abef97ea075c14be971a01a (diff)
ES6ify all the things!
Diffstat (limited to 'spec/javascripts/syntax_highlight_spec.js')
-rw-r--r--spec/javascripts/syntax_highlight_spec.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/javascripts/syntax_highlight_spec.js b/spec/javascripts/syntax_highlight_spec.js
new file mode 100644
index 00000000000..4e5dd1e59bf
--- /dev/null
+++ b/spec/javascripts/syntax_highlight_spec.js
@@ -0,0 +1,44 @@
+
+/*= 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 fixture.set('<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 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>");
+ });
+ 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('<div></div>');
+ highlight = function() {
+ return $('div').syntaxHighlight();
+ };
+ return expect(highlight).not.toThrow();
+ });
+ });
+ });
+
+}).call(this);