不要怂,就是干,撸起袖子干!

Commit c3273559 by Seth Samuel

Hstore empty string tests

1 parent bce115ad
Showing with 18 additions and 0 deletions
...@@ -68,6 +68,11 @@ if (dialect.match(/^postgres/)) { ...@@ -68,6 +68,11 @@ if (dialect.match(/^postgres/)) {
done() done()
}) })
it('should handle empty string correctly', function(done) {
expect(hstore.stringify({foo : ""})).to.equal('"foo"=>\"\"')
done()
})
it('should handle simple objects correctly', function(done) { it('should handle simple objects correctly', function(done) {
expect(hstore.stringify({ test: 'value' })).to.equal('"test"=>"value"') expect(hstore.stringify({ test: 'value' })).to.equal('"test"=>"value"')
done() done()
...@@ -100,6 +105,11 @@ if (dialect.match(/^postgres/)) { ...@@ -100,6 +105,11 @@ if (dialect.match(/^postgres/)) {
done() done()
}) })
it('should handle empty string correctly', function(done) {
expect(hstore.parse('"foo"=>\"\"')).to.equal({foo : ""})
done()
})
it('should handle empty objects correctly', function(done) { it('should handle empty objects correctly', function(done) {
expect(hstore.parse('')).to.deep.equal({ }) expect(hstore.parse('')).to.deep.equal({ })
done() done()
...@@ -130,5 +140,13 @@ if (dialect.match(/^postgres/)) { ...@@ -130,5 +140,13 @@ if (dialect.match(/^postgres/)) {
done() done()
}) })
}) })
describe('stringify and parse', function() {
it('should stringify then parse back the same structure', function(done){
var testObj = {foo : "bar", count : "1", emptyString : "", quotyString : "\"\"", nully : null};
expect(hstore.parse(hstore.stringify(testObj))).to.deep.equal(testObj);
expect(hstore.parse(hstore.stringify(hstore.parse(hstore.stringify(testObj))))).to.deep.equal(testObj);
done()
})
})
}) })
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!