plain.js 740 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. describe("protocal/plain", function () {
  2. var json, local, protocal;
  3. beforeEach(function () {
  4. protocal = KM.findProtocal('plain');
  5. });
  6. it('协议存在', function () {
  7. expect(protocal).toBeDefined();
  8. });
  9. it('正确 encode', function () {
  10. json = {
  11. data: {
  12. text: 'root',
  13. anyway: 'omg'
  14. },
  15. children: [{
  16. data: {
  17. text: 'l1c1'
  18. }
  19. }, {
  20. data: {
  21. text: 'l1c2'
  22. },
  23. children: [{
  24. data: {
  25. text: 'l2c1'
  26. }
  27. }, {
  28. data: {
  29. text: 'l2c2'
  30. }
  31. }]
  32. }, {
  33. data: {
  34. text: 'l1c3'
  35. }
  36. }]
  37. };
  38. local = protocal.encode(json);
  39. expect(local).toBe(
  40. 'root\n' +
  41. '\tl1c1\n' +
  42. '\tl1c2\n' +
  43. '\t\tl2c1\n' +
  44. '\t\tl2c2\n' +
  45. '\tl1c3\n'
  46. );
  47. });
  48. });