Permalink
Browse files

Fixed bug on tag deserialization of one tag.

  • Loading branch information...
1 parent d7e107d commit 1d4a0e9357be6824a7f89825f8948725708d28f1 @jprichardson committed Feb 23, 2013
Showing with 27 additions and 2 deletions.
  1. +4 −0 CHANGELOG.md
  2. +1 −1 lib/markdown-page.js
  3. +1 −1 package.json
  4. +21 −0 test/markdown-page.test.js
View
4 CHANGELOG.md
@@ -1,3 +1,7 @@
+0.1.2 / 2013-02-16
+------------------
+* Fixed deserialize bug on one tag. Added tests.
+
0.1.1 / 2013-01-31
------------------
* add `genOutput()` method
View
2 lib/markdown-page.js
@@ -123,7 +123,7 @@
deserialize: function (tagString) { //prob not very readable
if (S(tagString).contains(',')) return tagString.split(',').map(function(tag){ return tag.trim() })
else if (S(tagString).contains(' ')) return tagString.split(' ').map(function(tag){ return tag.trim() })
- else return tagString
+ else return [tagString]
},
serialize: function (tagArray) {
return tagArray.join(', ')
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "markdown-page",
- "version": "0.1.1",
+ "version": "0.1.2",
"description": "Parse a markdown article or page.",
"homepage": [
""
View
21 test/markdown-page.test.js
@@ -212,6 +212,27 @@ describe('MarkdownPage', function() {
})
})
})
+
+ describe('Metadata Conversions', function() {
+ describe('tags', function() {
+ it('should serialize from an array to a string', function() {
+ var serialize = (new MarkdownPage).metadataConversions.tags.serialize
+ EQ (serialize(['cars', 'planes']), 'cars, planes')
+ EQ (serialize(['cars']), 'cars')
+ })
+
+ it('should deserialize from a string to an array', function() {
+ var deserialize = (new MarkdownPage).metadataConversions.tags.deserialize
+ var a1 = ['cars', 'planes']
+ var a2 = ['cars']
+
+ EQ (deserialize('cars, planes')[0], a1[0])
+ EQ (deserialize('cars, planes')[1], a1[1])
+ EQ (deserialize('cars')[0], a2[0])
+ EQ (deserialize('cars')[0], a2[0])
+ })
+ })
+ })
})

0 comments on commit 1d4a0e9

Please sign in to comment.