This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): linkify error messages on minErr docs pages
- Loading branch information
Showing
2 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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('<a href="http://ab/">http://ab/</a> ' + | ||
'(<a href="http://a/">http://a/</a>) ' + | ||
'<a href="http://1.2/v:~-123">http://1.2/v:~-123</a>. c'); | ||
expect(errorLinkFilter(undefined)).not.toBeDefined(); | ||
}); | ||
|
||
it('should handle mailto', function () { | ||
expect(errorLinkFilter("mailto:[email protected]")). | ||
toBe('<a href="mailto:[email protected]">[email protected]</a>'); | ||
expect(errorLinkFilter("[email protected]")). | ||
toBe('<a href="mailto:[email protected]">[email protected]</a>'); | ||
expect(errorLinkFilter("send email to [email protected], but")). | ||
toBe('send email to <a href="mailto:[email protected]">[email protected]</a>, but'); | ||
}); | ||
|
||
it('should handle target', function () { | ||
expect(errorLinkFilter("http://example.com", "_blank")). | ||
toBe('<a target="_blank" href="http://example.com">http://example.com</a>') | ||
expect(errorLinkFilter("http://example.com", "someNamedIFrame")). | ||
toBe('<a target="someNamedIFrame" href="http://example.com">http://example.com</a>') | ||
}); | ||
|
||
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('<a href="http://errors.angularjs.org/very-long-version-string/$injector/nomod?p0=myApp">' + | ||
'http://errors.angularjs.org/very-long-version-string/$inj...</a>'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters