find.where.test.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. var Test = require('../../support/convert-runner');
  2. describe('Converter :: ', function() {
  3. describe('Find Where :: ', function() {
  4. it('should generate a find query', function() {
  5. Test({
  6. criteria: {
  7. model: 'user',
  8. method: 'find',
  9. criteria: {
  10. where: {
  11. and: [
  12. {
  13. firstName: 'Test'
  14. },
  15. {
  16. lastName: 'User'
  17. }
  18. ]
  19. }
  20. }
  21. },
  22. query: {
  23. select: [],
  24. from: 'user',
  25. where: {
  26. and: [
  27. {
  28. firstName: 'Test'
  29. },
  30. {
  31. lastName: 'User'
  32. }
  33. ]
  34. }
  35. }
  36. });
  37. });
  38. it('should work with operators', function() {
  39. Test({
  40. criteria: {
  41. model: 'user',
  42. method: 'find',
  43. criteria: {
  44. where: {
  45. votes: {
  46. '>': 100
  47. }
  48. }
  49. }
  50. },
  51. query: {
  52. select: [],
  53. from: 'user',
  54. where: {
  55. votes: {
  56. '>': 100
  57. }
  58. }
  59. }
  60. });
  61. });
  62. it('should work with multiple operators', function() {
  63. Test({
  64. criteria: {
  65. model: 'user',
  66. method: 'find',
  67. criteria: {
  68. where: {
  69. and: [
  70. {
  71. votes: {
  72. '>': 100
  73. }
  74. },
  75. {
  76. age: {
  77. '<': 50
  78. }
  79. }
  80. ]
  81. }
  82. }
  83. },
  84. query: {
  85. select: [],
  86. from: 'user',
  87. where: {
  88. and: [
  89. {
  90. votes: {
  91. '>': 100
  92. }
  93. },
  94. {
  95. age: {
  96. '<': 50
  97. }
  98. }
  99. ]
  100. }
  101. }
  102. });
  103. });
  104. });
  105. });