objectToSaneObject.coffee 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. require './_prepare'
  2. objectToSaneObject = mod 'objectToSaneObject'
  3. describe "sanitize()"
  4. test "case: 'text'", ->
  5. input = 'text'
  6. expectation = ['text']
  7. ret = objectToSaneObject.sanitize input
  8. ret.should.be.like expectation
  9. test "case: ['text']", ->
  10. input = ['text']
  11. expectation = ['text']
  12. ret = objectToSaneObject.sanitize input
  13. ret.should.be.like expectation
  14. test "case: {a:b}", ->
  15. input = a: 'b'
  16. expectation = [{a: ['b']}]
  17. ret = objectToSaneObject.sanitize input
  18. ret.should.be.like expectation
  19. test "case: {a:[b: 'c']}", ->
  20. input = a: [b: 'c']
  21. expectation = [{a: [{b: ['c']}]}]
  22. ret = objectToSaneObject.sanitize input
  23. ret.should.be.like expectation
  24. test "case: {a:b: 'c'}", ->
  25. input = a: b: 'c'
  26. expectation = [{
  27. a: [{
  28. b: ['c']
  29. }]
  30. }]
  31. ret = objectToSaneObject.sanitize input
  32. ret.should.be.like expectation
  33. test "case: {a:b: ['c', d: 'e']}", ->
  34. input = a: b: ['c', d: 'e']
  35. expectation = [{
  36. a: [{
  37. b: ['c', {d: ['e']}]
  38. }]
  39. }]
  40. ret = objectToSaneObject.sanitize input
  41. ret.should.be.like expectation