Add more CSON specs

This commit is contained in:
Kevin Sawicki
2013-02-04 08:40:16 -08:00
parent fd6795e748
commit ffc65b3735

View File

@@ -18,10 +18,6 @@ describe "CSON", ->
it "does not include the key in the formatted CSON", ->
expect(CSON.stringify(b: 1, c: undefined)).toBe "'b': 1"
describe "when formatting an empty object", ->
it "returns the empty string", ->
expect(CSON.stringify({})).toBe ""
describe "when formatting a string", ->
it "returns formatted CSON", ->
expect(CSON.stringify(a: 'b')).toBe "'a': 'b'"
@@ -32,18 +28,25 @@ describe "CSON", ->
it "doesn't escape double quotes", ->
expect(CSON.stringify(a: '"b"')).toBe "'a': '\"b\"'"
it "escapes newlines", ->
expect(CSON.stringify("a\nb")).toBe "'a\\nb'"
describe "when formatting a boolean", ->
it "returns formatted CSON", ->
expect(CSON.stringify(true)).toBe 'true'
expect(CSON.stringify(false)).toBe 'false'
expect(CSON.stringify(a: true)).toBe "'a': true"
expect(CSON.stringify(a: false)).toBe "'a': false"
describe "when formatting a number", ->
it "returns formatted CSON", ->
expect(CSON.stringify(54321.012345)).toBe '54321.012345'
expect(CSON.stringify(a: 14)).toBe "'a': 14"
expect(CSON.stringify(a: 1.23)).toBe "'a': 1.23"
describe "when formatting null", ->
it "returns formatted CSON", ->
expect(CSON.stringify(null)).toBe 'null'
expect(CSON.stringify(a: null)).toBe "'a': null"
describe "when formatting an array", ->
@@ -56,5 +59,9 @@ describe "CSON", ->
expect(CSON.stringify(a: ['b', 4])).toBe "'a': [\n 'b'\n 4\n]"
describe "when formatting an object", ->
describe "when the object is empty", ->
it "returns the empty string", ->
expect(CSON.stringify({})).toBe ""
it "returns formatted CSON", ->
expect(CSON.stringify(a: {b: 'c'})).toBe "'a':\n 'b': 'c'"