aboutsummaryrefslogtreecommitdiffstats
path: root/docs/component-spec
diff options
context:
space:
mode:
authorKen Sheedlo2013-08-22 14:56:42 -0600
committerBrian Ford2013-09-27 11:50:21 -0700
commit6aaae062171bfc8e5046c3eae99bc9d63037120a (patch)
treee78b3de544e5f956dcca0b56e5ef335fbf96ec76 /docs/component-spec
parent6a8edc1d43aca7c5a92f86309b1bb1d5f9968442 (diff)
downloadangular.js-6aaae062171bfc8e5046c3eae99bc9d63037120a.tar.bz2
feat(docs): linkify error messages on minErr docs pages
Diffstat (limited to 'docs/component-spec')
-rw-r--r--docs/component-spec/errorLinkFilterSpec.js49
1 files changed, 49 insertions, 0 deletions
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('<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:me@example.com")).
+ toBe('<a href="mailto:me@example.com">me@example.com</a>');
+ expect(errorLinkFilter("me@example.com")).
+ toBe('<a href="mailto:me@example.com">me@example.com</a>');
+ expect(errorLinkFilter("send email to me@example.com, but")).
+ toBe('send email to <a href="mailto:me@example.com">me@example.com</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>');
+ });
+}); \ No newline at end of file