David Chambers avatar David Chambers committed 7e5b660

Added unit tests for updates.

Comments (0)

Files changed (2)

templates/update.dhtml

-{% load mango_extras %}
-<div class="update"><div>
+<div class="update"><div>{% load mango_extras %}
 <h4>Update{% if update.datetime %} — <time datetime="{{ update.datetime|isoformat }}">{{ update.datetime|display_date }}</time>{% endif %}</h4>
 {{ update.html }}
 </div></div>
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
 from __future__ import with_statement
 import datetime
 import imp
         ''')
         self.assertEqual(document.excerpt, '<p><a href="http://mango.io/">Mango</a>.</p>')
 
+    def test_update_within_excerpt(self):
+        document = create_document(body='''
+            | Excerpt.
+            | 
+            | || [Markdown][] meets [Django][].
+            | 
+            | [Markdown]: http://daringfireball.net/projects/markdown/syntax
+            
+            [Django]: http://www.djangoproject.com/
+        ''')
+        self.assertEqual(document.excerpt, '\n'.join((
+                '<p>Excerpt.</p>',
+                '<div class="update"><div>',
+                '<h4>Update</h4>',
+                '<p><a href="http://daringfireball.net/projects/markdown/syntax">Markdown</a> meets <a href="http://www.djangoproject.com/">Django</a>.</p>',
+                '</div></div>\n')))
+
 
 class FileNameTests(unittest.TestCase):
 
         self.assertEqual(mango_extras.month(12), 'December')
 
 
+class UpdateTests(unittest.TestCase):
+
+    def setUp(self):
+        self.expected = '\n'.join((
+            '<p>%s</p>',
+            '<div class="update"><div>',
+            '<h4>Update</h4>',
+            '<p><a href="http://mango.io/">Mango</a>.</p>',
+            '</div></div>\n',
+        ))
+
+    def test_link_id_defined_in_inner_scope(self):
+        document = create_document(body='''
+            Text.
+            
+            || [Mango][1].
+            || 
+            || [1]: http://mango.io/
+        ''')
+        self.assertEqual(document.html, self.expected % 'Text.')
+
+    def test_link_id_defined_in_outer_scope(self):
+        document = create_document(body='''
+            Text.
+            
+            || [Mango][1].
+            
+            [1]: http://mango.io/
+        ''')
+        self.assertEqual(document.html, self.expected % 'Text.')
+
+    def test_link_id_defined_in_both_scopes(self):
+        document = create_document(body='''
+            [Django][1].
+            
+            || [Mango][1].
+            || 
+            || [1]: http://mango.io/
+            
+            [1]: http://www.djangoproject.com/
+        ''')
+        self.assertEqual(document.html, self.expected %
+                '<a href="http://www.djangoproject.com/">Django</a>.')
+
+
 class VideoTests(unittest.TestCase):
 
     def test_youtube(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.