From 389d4879da4aa620ee95d789b19ff9be44eb730a Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Wed, 12 Feb 2014 22:47:42 +0000 Subject: chore(doc-gen): new docs chore(doc-gen): implement dgeni --- docs/component-spec/NavigationCtrlSpec.js | 72 --------- docs/component-spec/annotationsSpec.js | 195 ------------------------- docs/component-spec/bootstrap/bootstrapSpec.js | 157 -------------------- docs/component-spec/bootstrap/code.html | 91 ------------ docs/component-spec/docsSearchSpec.js | 53 ------- docs/component-spec/errorDisplaySpec.js | 76 ---------- docs/component-spec/errorLinkFilterSpec.js | 52 ------- docs/component-spec/mocks.js | 32 ---- docs/component-spec/syntaxSpec.js | 50 ------- docs/component-spec/versionJumpSpec.js | 33 ----- 10 files changed, 811 deletions(-) delete mode 100644 docs/component-spec/NavigationCtrlSpec.js delete mode 100644 docs/component-spec/annotationsSpec.js delete mode 100644 docs/component-spec/bootstrap/bootstrapSpec.js delete mode 100644 docs/component-spec/bootstrap/code.html delete mode 100644 docs/component-spec/docsSearchSpec.js delete mode 100644 docs/component-spec/errorDisplaySpec.js delete mode 100644 docs/component-spec/errorLinkFilterSpec.js delete mode 100644 docs/component-spec/mocks.js delete mode 100644 docs/component-spec/syntaxSpec.js delete mode 100644 docs/component-spec/versionJumpSpec.js (limited to 'docs/component-spec') diff --git a/docs/component-spec/NavigationCtrlSpec.js b/docs/component-spec/NavigationCtrlSpec.js deleted file mode 100644 index d7a9da45..00000000 --- a/docs/component-spec/NavigationCtrlSpec.js +++ /dev/null @@ -1,72 +0,0 @@ -describe("DocsNavigationCtrl", function() { - - beforeEach(module('docsApp')); - - var ctrl, $scope; - - beforeEach(function() { - module(function($provide) { - $provide.value('docsPages', []); - $provide.factory('docsSearch', function() { - return function(q) { - return ['one','two','three']; - }; - }); - }); - inject(function($controller, $rootScope, $location, docsSearch) { - $scope = $rootScope.$new(); - ctrl = $controller('DocsNavigationCtrl', { - $scope : $scope, - $location : $location, - docsSearch : docsSearch - }); - }); - }); - - it("should search and return data from docsSearch", function() { - $scope.search('1234') - expect($scope.results.join(',')).toBe('one,two,three'); - expect($scope.hasResults).toBe(true); - }); - - it("should avoid searching if the search term is too short", function() { - $scope.search('1') - expect($scope.results.length).toBe(0); - expect($scope.hasResults).toBe(false); - }); - - it("should set the columns classname based on the total grouped results", function() { - $scope.search('1234'); - expect($scope.colClassName).toBe('cols-3'); - - $scope.search('1'); - expect($scope.colClassName).toBe(null); - }); - - it("should hide and clear the results when called", function() { - $scope.hasResults = true; - $scope.results = ['one']; - $scope.colClassName = '...'; - $scope.hideResults(); - expect($scope.hasResults).toBe(false); - expect($scope.results.length).toBe(0); - expect($scope.colClassName).toBe(null); - }); - - it("should hide, clear and change the path of the page when submitted", inject(function($location) { - $scope.hasResults = true; - $scope.results = { - api : [ - {url : '/home'} - ], - tutorial : [ - {url : '/tutorial'} - ] - }; - $scope.submit(); - expect($location.path()).toBe('/home'); - expect($scope.results.length).toBe(0); - expect($scope.hasResults).toBe(false); - })); - -}); diff --git a/docs/component-spec/annotationsSpec.js b/docs/component-spec/annotationsSpec.js deleted file mode 100644 index 60b17d9a..00000000 --- a/docs/component-spec/annotationsSpec.js +++ /dev/null @@ -1,195 +0,0 @@ -describe('Docs Annotations', function() { - - beforeEach(module('docsApp')); - - var body; - beforeEach(function() { - body = angular.element(document.body); - body.empty(); - }); - - var normalizeHtml = function(html) { - return html.toLowerCase().replace(/\s*$/, ''); - }; - - describe('popover directive', function() { - - var $scope, element; - beforeEach(inject(function($rootScope, $compile) { - $scope = $rootScope.$new(); - element = angular.element( - '
' - ); - element.attr('id','idx'); - body.append(element); - $compile(element)($scope); - $scope.$apply(); - })); - - it('should be hidden by default', inject(function(popoverElement) { - expect(popoverElement.visible()).toBe(false); - })); - - it('should capture the click event and set the title and content and position the tip', inject(function(popoverElement) { - element.triggerHandler('click'); - expect(popoverElement.isSituatedAt(element)).toBe(true); - expect(popoverElement.visible()).toBe(true); - expect(popoverElement.title()).toBe('title_text'); - expect(popoverElement.content()).toContain('content_text'); - expect(popoverElement.besideElement.attr('id')).toBe('idx'); - })); - - it('should hide and clear the title and content if the same element is clicked again', inject(function(popoverElement) { - //show the element - element.triggerHandler('click'); - expect(popoverElement.isSituatedAt(element)).toBe(true); - - //hide the element - element.triggerHandler('click'); - expect(popoverElement.isSituatedAt(element)).toBe(false); - expect(popoverElement.visible()).toBe(false); - expect(popoverElement.title()).toBe(''); - expect(popoverElement.content()).toBe(''); - })); - - it('should parse markdown content', inject(function(popoverElement, $compile) { - element = angular.element( - '
' - ); - body.append(element); - $compile(element)($scope); - $scope.$apply(); - element.triggerHandler('click'); - expect(popoverElement.title()).toBe('#title_text'); - expect(normalizeHtml(popoverElement.content())).toMatch('

heading

'); - })); - - }); - - - describe('foldout directive', function() { - - // Do not run this suite on Internet Explorer. - if (msie < 10) return; - - var $scope, parent, element, url; - beforeEach(function() { - module(function($provide, $animateProvider) { - $animateProvider.register('.foldout', function($timeout) { - return { - enter : function(element, done) { - $timeout(done, 1000); - }, - removeClass : function(element, className, done) { - $timeout(done, 500); - }, - addClass : function(element, className, done) { - $timeout(done, 200); - } - } - }); - }); - inject(function($rootScope, $compile, $templateCache, $rootElement, $animate) { - $animate.enabled(true); - url = '/page.html'; - $scope = $rootScope.$new(); - parent = angular.element('
'); - - //we're injecting the element to the $rootElement since the changes in - //$animate only detect and perform animations if the root element has - //animations enabled. If the element is not apart of the DOM - //then animations are skipped. - element = angular.element('
'); - parent.append(element); - $rootElement.append(parent); - body.append($rootElement); - - $compile(parent)($scope); - $scope.$apply(); - }); - }); - - it('should inform that it is loading', inject(function($httpBackend) { - $httpBackend.expect('GET', url).respond('hello'); - element.triggerHandler('click'); - - var kids = body.children(); - var foldout = angular.element(kids[kids.length-1]); - expect(foldout.html()).toContain('loading'); - })); - - //TODO(matias): this test is bad. it's not clear what is being tested and what the assertions are. - // Additionally, now that promises get auto-flushed there are extra tasks in the deferred queue which screws up - // these brittle tests. - xit('should download a foldout HTML page and animate the contents', inject(function($httpBackend, $timeout, $sniffer) { - $httpBackend.expect('GET', url).respond('hello'); - - element.triggerHandler('click'); - $httpBackend.flush(); - - $timeout.flushNext(0); - $timeout.flushNext(1000); - - var kids = body.children(); - var foldout = angular.element(kids[kids.length-1]); - expect(foldout.text()).toContain('hello'); - })); - - //TODO(matias): this test is bad. it's not clear what is being tested and what the assertions are. - // Additionally, now that promises get auto-flushed there are extra tasks in the deferred queue which screws up - // these brittle tests. - xit('should hide then show when clicked again', inject(function($httpBackend, $timeout, $sniffer) { - $httpBackend.expect('GET', url).respond('hello'); - - //enter - element.triggerHandler('click'); - $httpBackend.flush(); - $timeout.flushNext(0); - $timeout.flushNext(1000); - - //hide - element.triggerHandler('click'); - $timeout.flushNext(0); - $timeout.flushNext(200); - - //show - element.triggerHandler('click'); - $timeout.flushNext(0); - $timeout.flushNext(500); - $timeout.flushNext(0); - })); - - }); - - describe('DocsController fold', function() { - - var $scope, ctrl; - beforeEach(function() { - inject(function($rootScope, $controller, $location, $cookies, sections) { - $scope = $rootScope.$new(); - ctrl = $controller('DocsController',{ - $scope : $scope, - $location : $location, - $cookies : $cookies, - sections : sections - }); - }); - }); - - it('should download and reveal the foldover container', inject(function($compile, $httpBackend) { - var url = '/page.html'; - var fullUrl = '/notes/' + url; - $httpBackend.expect('GET', fullUrl).respond('hello'); - - var element = angular.element('
'); - $compile(element)($scope); - $scope.$apply(); - - $scope.fold(url); - - $httpBackend.flush(); - })); - - }); - -}); diff --git a/docs/component-spec/bootstrap/bootstrapSpec.js b/docs/component-spec/bootstrap/bootstrapSpec.js deleted file mode 100644 index 2c8d89fa..00000000 --- a/docs/component-spec/bootstrap/bootstrapSpec.js +++ /dev/null @@ -1,157 +0,0 @@ -'use strict'; - -describe('bootstrap', function() { - var $compile, $rootScope, element; - - function clickTab(element, index) { - browserTrigger(element.children().eq(0).children().eq(index)); - } - - beforeEach(module('bootstrap')); - beforeEach(inject(function(_$compile_, _$rootScope_) { - $compile = _$compile_; - $rootScope = _$rootScope_; - })); - beforeEach(function(){ - function findTab(element, index) { - return _jQuery(element[0]).find('> .nav-tabs > li').eq(index); - } - function findTabPane(element, index) { - return _jQuery(element[0]).find('> .tab-content > .tab-pane').eq(index); - } - - this.addMatchers({ - toHaveTab: function(index, title) { - var tab = findTab(element, index); - - this.message = function() { - if (tab.length) { - return 'Expect tab index ' + index + ' to be ' + toJson(title) + ' but was ' + toJson(tab.text()); - } else { - return 'Expect tab index ' + index + ' to be ' + toJson(title) + ' but there are only ' + - element.children().length + ' tabs.'; - } - }; - - return tab.length && tab.text() == title; - }, - - toHaveTabPane: function(index, title) { - var tabPane = findTabPane(element, index); - - this.message = function() { - if (tabPane.length) { - return 'Expect tab pane index ' + index + ' to be ' + toJson(title) + ' but was ' + toJson(tabPane.text()); - } else { - return 'Expect tab pane index ' + index + ' to be ' + toJson(title) + ' but there are only ' + - element.children().length + 'tab panes.'; - } - }; - - return tabPane.length && tabPane.text() == title; - }, - - toHaveSelected: function(index) { - var tab = findTab(element, index); - var tabPane = findTabPane(element, index); - - this.message = function() { - return 'Expect tab index ' + index + ' to be selected\n' + - ' TAB: ' + angular.mock.dump(tab) + '\n' + - 'TAB-PANE: ' + angular.mock.dump(tabPane); - }; - - return tabPane.hasClass('active') && tab.hasClass('active'); - } - }); - }); - - afterEach(function() { - dealoc(element); - }); - - describe('tabbable', function() { - - it('should create the right structure', function() { - element = $compile( - '
' + - '
tab1
' + - '
tab2
' + - '
')($rootScope); - - $rootScope.$apply(); - - expect(element).toHaveTab(0, 'first'); - expect(element).toHaveTab(1, 'second'); - - expect(element).toHaveTabPane(0, 'tab1'); - expect(element).toHaveTabPane(1, 'tab2'); - - expect(element).toHaveSelected(0); - }); - - - it('should respond to tab click', function(){ - element = $compile( - '
' + - '
tab1
' + - '
tab2
' + - '
')($rootScope); - - expect(element).toHaveSelected(0); - clickTab(element, 1); - expect(element).toHaveSelected(1); - }); - - - it('should select the first tab in repeater', function() { - element = $compile( - '
' + - '
' + - 'Tab content {{id}}!' + - '
' + - '
')($rootScope); - $rootScope.$apply(); - - expect(element).toHaveSelected(0); - }); - - - describe('ngModel', function() { - it('should bind to model', function() { - $rootScope.tab = 'B'; - - element = $compile( - '
' + - '
tab1
' + - '
tab2
' + - '
')($rootScope); - - $rootScope.$apply(); - expect(element).toHaveSelected(1); - - $rootScope.tab = 'A'; - $rootScope.$apply(); - expect(element).toHaveSelected(0); - - clickTab(element, 1); - expect($rootScope.tab).toEqual('B'); - expect(element).toHaveSelected(1); - }); - - - it('should not overwrite the model', function() { - $rootScope.tab = 'tab-2'; - element = $compile( - '
' + - '
' + - 'Tab content {{id}}!' + - '
' + - '
')($rootScope); - $rootScope.$apply(); - - expect(element).toHaveSelected(1); - }); - }); - }); -}); diff --git a/docs/component-spec/bootstrap/code.html b/docs/component-spec/bootstrap/code.html deleted file mode 100644 index e1eaa8d2..00000000 --- a/docs/component-spec/bootstrap/code.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - -
-
-
-

AngularJS is {{'working'}}

- -

Directive: prettify

-
-            <p>Sample text here...</p>
-          
- - -

Directive: ng-set-text

-

-          
-
-          

Directive: ng-html-wrap

-

-
-          

Directive ng-embed-app

-
{{text}}
- -

Bootstrap

- -

Directive drop-down-toggle

- - -

Directive tabbable

- state = {{state}} - -
-
- Tab content {{id}}! -
-
- -
- -
-
- Tab content {{id}}! -
-
- -
- -
-
- Tab content {{id}}! -
-
- -
-
-
-
-
-
-
-
-
- - diff --git a/docs/component-spec/docsSearchSpec.js b/docs/component-spec/docsSearchSpec.js deleted file mode 100644 index f5f8d36e..00000000 --- a/docs/component-spec/docsSearchSpec.js +++ /dev/null @@ -1,53 +0,0 @@ -describe("docsSearch", function() { - - beforeEach(module('docsApp')); - - var interceptedLunrResults; - beforeEach(function() { - interceptedLunrResults = []; - }); - - beforeEach(function() { - module(function($provide) { - var results = []; - results[0] = { section: 'tutorial', shortName: 'item one', keywords: 'item, one, 1' }; - results[1] = { section: 'tutorial', shortName: 'item man', keywords: 'item, man' }; - results[2] = { section: 'api', shortName: 'item other', keywords: 'item, other' }; - results[3] = { section: 'api', shortName: 'ngRepeat', keywords: 'item, other' }; - - $provide.value('NG_PAGES', results); - $provide.factory('lunrSearch', function() { - return function() { - return { - store : function(value) { - interceptedLunrResults.push(value); - }, - search : function(q) { - var data = []; - angular.forEach(results, function(res, i) { - data.push({ ref : i }); - }); - return data; - } - } - }; - }); - }); - }); - - it("should lookup and organize values properly", inject(function(docsSearch) { - var items = docsSearch('item'); - expect(items['api'].length).toBe(2); - })); - - it("should return all results without a search", inject(function(docsSearch) { - var items = docsSearch(); - expect(items['tutorial'].length).toBe(2); - expect(items['api'].length).toBe(2); - })); - - it("should store values with and without a ng prefix", inject(function(docsSearch) { - expect(interceptedLunrResults[3].title).toBe('ngRepeat repeat'); - })); - -}); diff --git a/docs/component-spec/errorDisplaySpec.js b/docs/component-spec/errorDisplaySpec.js deleted file mode 100644 index 9549e220..00000000 --- a/docs/component-spec/errorDisplaySpec.js +++ /dev/null @@ -1,76 +0,0 @@ -describe("errorDisplay", function () { - - var $location, compileHTML; - - beforeEach(module('docsApp')); - - beforeEach(inject(function ($injector) { - var $rootScope = $injector.get('$rootScope'), - $compile = $injector.get('$compile'); - - $location = $injector.get('$location'); - - compileHTML = function (code) { - var elm = angular.element(code); - $compile(elm)($rootScope); - $rootScope.$digest(); - return elm; - }; - - this.addMatchers({ - toInterpolateTo: function (expected) { - // Given a compiled DOM node with a minerr-display attribute, - // assert that its interpolated string matches the expected text. - return this.actual.text() === expected; - } - }); - })); - - it('should interpolate a template with no parameters', function () { - var elm; - - spyOn($location, 'search').andReturn({}); - elm = compileHTML('
'); - expect(elm).toInterpolateTo('This is a test'); - }); - - it('should interpolate a template with no parameters when search parameters are present', function () { - var elm; - - spyOn($location, 'search').andReturn({ p0: 'foobaz' }); - elm = compileHTML('
'); - expect(elm).toInterpolateTo('This is a test'); - }); - - it('should correctly interpolate search parameters', function () { - var elm; - - spyOn($location, 'search').andReturn({ p0: '42' }); - elm = compileHTML('
'); - expect(elm).toInterpolateTo('The answer is 42'); - }); - - it('should interpolate parameters in the specified order', function () { - var elm; - - spyOn($location, 'search').andReturn({ p0: 'second', p1: 'first' }); - elm = compileHTML('
'); - expect(elm).toInterpolateTo('first second'); - }); - - it('should preserve interpolation markers when fewer arguments than needed are provided', function () { - var elm; - - spyOn($location, 'search').andReturn({ p0: 'Fooooo' }); - elm = compileHTML('
'); - expect(elm).toInterpolateTo('This Fooooo is {1} on {2}'); - }); - - it('should correctly handle the empty string as an interpolation parameter', function () { - var elm; - - spyOn($location, 'search').andReturn({ p0: 'test', p1: '' }); - elm = compileHTML('
'); - expect(elm).toInterpolateTo('This test is a '); - }); -}); \ No newline at end of file diff --git a/docs/component-spec/errorLinkFilterSpec.js b/docs/component-spec/errorLinkFilterSpec.js deleted file mode 100644 index 1b3cbf73..00000000 --- a/docs/component-spec/errorLinkFilterSpec.js +++ /dev/null @@ -1,52 +0,0 @@ -describe("errorLinkFilter", function () { - - var errorLinkFilter; - - beforeEach(module('docsApp')); - - beforeEach(inject(function ($filter) { - errorLinkFilter = $filter('errorLink'); - })); - - it('should not change text that does not contain links', function () { - expect(errorLinkFilter('This is a test')).toBe('This is a test'); - }); - - it('should find links in text and linkify them', function () { - var output = errorLinkFilter("http://ab/ (http://a/) http://1.2/v:~-123. c"); - //temporary fix for IE8 sanitization whitespace bug - output = output.replace('(',' ('); - expect(output). - toBe('http://ab/ ' + - '(http://a/) ' + - 'http://1.2/v:~-123. c'); - expect(errorLinkFilter(undefined)).not.toBeDefined(); - }); - - it('should handle mailto', function () { - expect(errorLinkFilter("mailto:me@example.com")). - toBe('me@example.com'); - expect(errorLinkFilter("me@example.com")). - toBe('me@example.com'); - expect(errorLinkFilter("send email to me@example.com, but")). - toBe('send email to me@example.com, but'); - }); - - it('should handle target', function () { - expect(errorLinkFilter("http://example.com", "_blank")). - toBe('http://example.com') - expect(errorLinkFilter("http://example.com", "someNamedIFrame")). - toBe('http://example.com') - }); - - it('should not linkify stack trace URLs', function () { - expect(errorLinkFilter("http://example.com/angular.min.js:42:1337")). - toBe("http://example.com/angular.min.js:42:1337"); - }); - - it('should truncate linked URLs at 60 characters', function () { - expect(errorLinkFilter("http://errors.angularjs.org/very-long-version-string/$injector/nomod?p0=myApp")). - toBe('' + - 'http://errors.angularjs.org/very-long-version-string/$inj...'); - }); -}); diff --git a/docs/component-spec/mocks.js b/docs/component-spec/mocks.js deleted file mode 100644 index f916c0ed..00000000 --- a/docs/component-spec/mocks.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copy/pasted from src/Angular.js, so that we can disable specific tests on IE. -var msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1], 10); - -var createMockWindow = function() { - var mockWindow = {}; - var setTimeoutQueue = []; - - mockWindow.location = window.location; - mockWindow.document = window.document; - mockWindow.getComputedStyle = angular.bind(window, window.getComputedStyle); - mockWindow.scrollTo = angular.bind(window, window.scrollTo); - mockWindow.navigator = window.navigator; - mockWindow.setTimeout = function(fn, delay) { - setTimeoutQueue.push({fn: fn, delay: delay}); - }; - mockWindow.setTimeout.queue = setTimeoutQueue; - mockWindow.setTimeout.expect = function(delay) { - if (setTimeoutQueue.length > 0) { - return { - process: function() { - var tick = setTimeoutQueue.shift(); - expect(tick.delay).toEqual(delay); - tick.fn(); - } - }; - } else { - expect('SetTimoutQueue empty. Expecting delay of ').toEqual(delay); - } - }; - - return mockWindow; -}; diff --git a/docs/component-spec/syntaxSpec.js b/docs/component-spec/syntaxSpec.js deleted file mode 100644 index 2868602b..00000000 --- a/docs/component-spec/syntaxSpec.js +++ /dev/null @@ -1,50 +0,0 @@ -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/component-spec/versionJumpSpec.js b/docs/component-spec/versionJumpSpec.js deleted file mode 100644 index bb43231a..00000000 --- a/docs/component-spec/versionJumpSpec.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('DocsApp', function() { - - // Do not run this suite on Internet Explorer. - if (msie < 10) return; - - beforeEach(module('docsApp')); - - describe('DocsVersionsCtrl', function() { - var $scope, ctrl, window, version = '9.8.7'; - - beforeEach(function() { - module(function($provide) { - $provide.value('$window', window = createMockWindow()); - }); - inject(function($controller, $rootScope) { - $scope = $rootScope.$new(); - $scope.version = version; - ctrl = $controller('DocsVersionsCtrl',{ - $scope : $scope, - $window : window - }); - }); - }); - - describe('changing the URL', function() { - it('should jump to the url provided', function() { - $scope.jumpToDocsVersion({ version: '1.0.1', url : 'page123'}); - expect(window.location).toBe('page123'); - }); - }); - }); - -}); -- cgit v1.2.3