Guest User

Untitled

a guest
Mar 5th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. const jrf = require('./lib/index')
  2.  
  3. data = {
  4. uuid: 'main-uuid',
  5. username: 'lucas',
  6. password: '565-6.-5656-54-54-564-',
  7. timestamp: {
  8. uuid: 'timestamp-uuid',
  9. created_at: '10/05/2019',
  10. updated_at: '11/05/2019',
  11. deleted_at: null
  12. }
  13. }
  14.  
  15. console.log('Teste 1 fields: ',
  16. JSON.stringify(jrf.only(data, ['uuid', 'username', 'created_at'])) == JSON.stringify({
  17. uuid: 'main-uuid',
  18. username: 'lucas',
  19. timestamp: {
  20. uuid: 'timestamp-uuid',
  21. created_at: '10/05/2019',
  22. }
  23. }) ? 'Sucesso' : 'Falhou'
  24. )
  25.  
  26. data = {
  27. uuid: 'main-uuid',
  28. username: 'lucas',
  29. password: '565-6.-5656-54-54-564-',
  30. timestamp: {
  31. uuid: 'timestamp-uuid',
  32. created_at: '10/05/2019',
  33. updated_at: '11/05/2019',
  34. deleted_at: null
  35. }
  36. }
  37.  
  38. console.log('Teste 2 fields: ',
  39. JSON.stringify(jrf.only(data, ['username'])) == JSON.stringify({
  40. username: 'lucas'
  41. }) ? 'Sucesso' : 'Falhou'
  42. )
  43.  
  44. data = {
  45. uuid: 'main-uuid',
  46. username: 'lucas',
  47. password: '565-6.-5656-54-54-564-',
  48. timestamp: {
  49. uuid: 'timestamp-uuid',
  50. created_at: '10/05/2019',
  51. updated_at: '11/05/2019',
  52. deleted_at: null
  53. }
  54. }
  55.  
  56. console.log('Teste 3 fields: ',
  57. JSON.stringify(jrf.only(data, ['uuid', 'username', 'created_at', 'timestamp'])) == JSON.stringify({
  58. uuid: 'main-uuid',
  59. username: 'lucas',
  60. timestamp: {
  61. uuid: 'timestamp-uuid',
  62. created_at: '10/05/2019',
  63. updated_at: '11/05/2019',
  64. deleted_at: null
  65. }
  66. }) ? 'Sucesso' : 'Falhou'
  67. )
  68.  
  69. data = ['foo', 'bar', 'foobar']
  70.  
  71. console.log('Teste 4 fields: ',
  72. JSON.stringify(jrf.only(data, ['foo', 'foobar'])) == JSON.stringify(['foo', 'foobar']) ? 'Sucesso' : 'Falhou'
  73. )
  74.  
  75. data = [['foo', 'bar'], 'foobar']
  76.  
  77. console.log('Teste 5 fields: ',
  78. JSON.stringify(jrf.only(data, ['foo', 'foobar'])) == JSON.stringify([['foo'], 'foobar']) ? 'Sucesso' : 'Falhou'
  79. )
  80.  
  81. data = [['foo', 'bar'], {foobar: {uuid: 'teste-uuid', username: 'lucas'}}]
  82.  
  83. console.log('Teste 6 fields: ',
  84. JSON.stringify(jrf.only(data, ['foo', 'uuid'])) == JSON.stringify([['foo'], {foobar: {uuid: 'teste-uuid'}}]) ? 'Sucesso' : 'Falhou'
  85. )
  86.  
  87. data = [['foo', 'bar'], {foobar: {uuid: 'teste-uuid', username: 'lucas'}}]
  88.  
  89. console.log('Teste 7 fields: ',
  90. JSON.stringify(jrf.only(data, ['foo', 'foobar'])) == JSON.stringify([['foo'], {foobar: {uuid: 'teste-uuid', username: 'lucas'}}]) ? 'Sucesso' : 'Falhou'
  91. )
Add Comment
Please, Sign In to add comment