From 6aaae062171bfc8e5046c3eae99bc9d63037120a Mon Sep 17 00:00:00 2001 From: Ken Sheedlo Date: Thu, 22 Aug 2013 14:56:42 -0600 Subject: feat(docs): linkify error messages on minErr docs pages --- docs/component-spec/errorLinkFilterSpec.js | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 docs/component-spec/errorLinkFilterSpec.js (limited to 'docs/component-spec') diff --git a/docs/component-spec/errorLinkFilterSpec.js b/docs/component-spec/errorLinkFilterSpec.js new file mode 100644 index 00000000..36f5f46b --- /dev/null +++ b/docs/component-spec/errorLinkFilterSpec.js @@ -0,0 +1,49 @@ +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 () { + expect(errorLinkFilter("http://ab/ (http://a/) http://1.2/v:~-123. c")). + 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...'); + }); +}); \ No newline at end of file -- cgit v1.2.3