康巴易测肤/伤疤uniapp小程序类
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 line
2.1KB

  1. import {deepDecodeQuery} from '../src/helpers/utils';
  2. it('编码回转',()=>{
  3. const query={
  4. str:'%E7%9A%84%E6%8C%A5%E6%B4%92U%E7%9B%BE%E5%A5%BD%E6%92%92%E7%AC%AC%E4%B8%89%E5%A4%A7%E5%8E%A6%E5%8F%91%E7%9A%84%E6%92%92321312%2a%EF%BC%88%EF%BF%A5%23%254'
  5. }
  6. const result = deepDecodeQuery(query);
  7. expect(JSON.stringify(result)).toEqual(JSON.stringify({
  8. str:'的挥洒U盾好撒第三大厦发的撒321312*(¥#%4'
  9. }))
  10. })
  11. it('一些乱码字符',()=>{
  12. const query={
  13. str:`~!@#$%^&*()_+-,./|][]`
  14. }
  15. const result = deepDecodeQuery(query);
  16. expect(JSON.stringify(result)).toEqual(JSON.stringify({
  17. str:`~!@#$%^&*()_+-,./|][]`
  18. }))
  19. })
  20. it('单个加密参数',()=>{
  21. const query={
  22. name:'%7B%22status%22%3Atrue%2C%22list%22%3A%5B%7B%22id%22%3A1%7D%5D%7D'
  23. }
  24. const result = deepDecodeQuery(query);
  25. expect(JSON.stringify(result)).toEqual(JSON.stringify({
  26. name:{
  27. status:true,
  28. list:[
  29. {
  30. id:1
  31. },
  32. ]
  33. }
  34. }));
  35. })
  36. it('单个普通参数',()=>{
  37. const query={
  38. name:'hhyang',
  39. ages:22,
  40. open:true
  41. }
  42. const result = deepDecodeQuery(query);
  43. expect(JSON.stringify(result)).toEqual(JSON.stringify(query));
  44. })
  45. it('深度参数加混乱',()=>{
  46. const query={
  47. list:[
  48. 1,'2',true,encodeURIComponent(JSON.stringify({name:111})),{
  49. name:'hhyang',
  50. strObj:encodeURIComponent(JSON.stringify({name:222}))
  51. }
  52. ],
  53. obj:{
  54. strObj2:encodeURIComponent(JSON.stringify({name:333})),
  55. number:1,
  56. boolean:false,
  57. },
  58. str4:encodeURIComponent(JSON.stringify({name:444}))
  59. }
  60. const result = deepDecodeQuery(query);
  61. expect(JSON.stringify(result)).toEqual(JSON.stringify({
  62. list:[
  63. 1,'2',true,{name:111},{
  64. name:'hhyang',
  65. strObj:{name:222}
  66. }
  67. ],
  68. obj:{
  69. strObj2:{name:333},
  70. number:1,
  71. boolean:false,
  72. },
  73. str4:{name:444}
  74. }));
  75. })