@autofleet/sheilta 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,7 +53,7 @@ const validateQueryPayload = (query, rawAttributes) => {
53
53
  });
54
54
  };
55
55
  exports.validatePayload = ({ query = {}, order = [], attributes = [], }, model) => {
56
- const { rawAttributes } = model;
56
+ const rawAttributes = Object.keys(model.rawAttributes);
57
57
  if (!attributes || attributes.length === 0) {
58
58
  // eslint-disable-next-line no-param-reassign
59
59
  attributes = rawAttributes;
@@ -39,16 +39,28 @@ const query = {
39
39
  const order = ['startTime', '-endTime'];
40
40
  describe('validations test', () => {
41
41
  it('check query validation', () => {
42
- const payload = _1.validatePayload({ query }, { rawAttributes: ['startTime', 'endTime', 'currencySymbol', 'currencyCode', 'startStationId'] });
42
+ const payload = _1.validatePayload({ query }, {
43
+ rawAttributes: {
44
+ startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
45
+ },
46
+ });
43
47
  expect(payload).toBe(true);
44
48
  });
45
49
  it('check order validation', () => {
46
- const payload = _1.validatePayload({ order }, { rawAttributes: ['startTime', 'endTime', 'currencySymbol', 'currencyCode', 'startStationId'] });
50
+ const payload = _1.validatePayload({ order }, {
51
+ rawAttributes: {
52
+ startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
53
+ },
54
+ });
47
55
  expect(payload).toBe(true);
48
56
  });
49
57
  it('check order validation - order does not exist', () => {
50
58
  try {
51
- _1.validatePayload({ order: ['aviv'] }, { rawAttributes: ['startTime', 'endTime', 'currencySymbol', 'currencyCode', 'startStationId'] });
59
+ _1.validatePayload({ order: ['aviv'] }, {
60
+ rawAttributes: {
61
+ startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
62
+ },
63
+ });
52
64
  }
53
65
  catch (error) {
54
66
  expect(error.statusCode).toBe(400);
@@ -56,7 +68,11 @@ describe('validations test', () => {
56
68
  });
57
69
  it('check order validation - prefix in the wrong place', () => {
58
70
  try {
59
- _1.validatePayload({ order: ['startTime-', 'currencySymbol'] }, { rawAttributes: ['startTime', 'endTime', 'currencySymbol', 'currencyCode', 'startStationId'] });
71
+ _1.validatePayload({ order: ['startTime-', 'currencySymbol'] }, {
72
+ rawAttributes: {
73
+ startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
74
+ },
75
+ });
60
76
  }
61
77
  catch (error) {
62
78
  expect(error.statusCode).toBe(400);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sheilta",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "manage cache",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",