From 5f92d4144ea3c8c8fc33e163b3973401b527a4bd Mon Sep 17 00:00:00 2001
From: Matias Niemelä
Date: Thu, 16 May 2013 16:05:21 -0400
Subject: fix(ngdocs): provide test code for syntax links in docs and fix the
 syntax directive for IE8
---
 docs/component-spec/syntaxSpec.js      | 50 ++++++++++++++++++++++++++++++++++
 docs/components/bootstrap/bootstrap.js | 12 +++++---
 2 files changed, 58 insertions(+), 4 deletions(-)
 create mode 100644 docs/component-spec/syntaxSpec.js
(limited to 'docs')
diff --git a/docs/component-spec/syntaxSpec.js b/docs/component-spec/syntaxSpec.js
new file mode 100644
index 00000000..2868602b
--- /dev/null
+++ b/docs/component-spec/syntaxSpec.js
@@ -0,0 +1,50 @@
+describe('Docs Syntax', function() {
+
+  beforeEach(module('bootstrap'));
+
+  describe('syntax', function() {
+
+    var id, element, document;
+
+    beforeEach(inject(function($compile, $rootScope, $document) {
+      document = $document[0];
+      //create the HTML elements missing in IE8 for this directive
+      document.createElement('nav');
+
+      element = angular.element(
+        '
'
+      );
+      $compile(element)($rootScope);
+      $rootScope.$digest();
+
+      element = element[0];
+      document.body.appendChild(element);
+    }));
+
+    it("should properly prepare a github link in the page", function() {
+      var github = element.querySelector('.syntax-github');
+      expect(github.innerHTML).toMatch(/View on Github/i);
+      expect(github.getAttribute('href')).toBe('gh-url');
+    });
+
+    it("should properly prepare a plunkr link in the page", function() {
+      var plunkr = element.querySelector('.syntax-plunkr');
+      expect(plunkr.innerHTML).toMatch(/View on Plunkr/i);
+      expect(plunkr.getAttribute('href')).toBe('pl-url');
+    });
+
+    it("should properly prepare a jsfiddle link in the page", function() {
+      var jsfiddle = element.querySelector('.syntax-jsfiddle');
+      expect(jsfiddle.innerHTML).toMatch(/View on JSFiddle/i);
+      expect(jsfiddle.getAttribute('href')).toBe('jf-url');
+    });
+
+  });
+
+});
diff --git a/docs/components/bootstrap/bootstrap.js b/docs/components/bootstrap/bootstrap.js
index 91d6590e..3e1c8d00 100644
--- a/docs/components/bootstrap/bootstrap.js
+++ b/docs/components/bootstrap/bootstrap.js
@@ -57,7 +57,8 @@ directive.syntax = function() {
                 ' ' + text +
                '';
       };
-      var html = '';
-      var nav = angular.element(html);
+
+      var nav = document.createElement('nav');
+      nav.className = 'syntax-links';
+      nav.innerHTML = html;
+
       var node = element[0];
       var par = node.parentNode;
-      par.insertBefore(nav[0], node);
+      par.insertBefore(nav, node);
     }
   }
 }
-- 
cgit v1.2.3