From 2439363dfbd87edc265e1092c2bac5e689e6d063 Mon Sep 17 00:00:00 2001 From: Slava Rudkovskiy Date: Tue, 27 Mar 2018 16:45:10 +0300 Subject: [PATCH] Add test for filter parameter in list methods --- test/services/LicenseServiceTest.js | 14 ++++++++++++++ test/services/LicenseTemplateServiceTest.js | 14 ++++++++++++++ test/services/LicenseeServiceTest.js | 13 +++++++++++++ test/services/ProductModuleServiceTest.js | 14 ++++++++++++++ test/services/ProductServiceTest.js | 14 ++++++++++++++ test/services/TokenServiceTest.js | 14 ++++++++++++++ test/services/TransactionServiceTest.js | 14 ++++++++++++++ test/services/UtilityServiceTest.js | 14 ++++++++++++++ 8 files changed, 111 insertions(+) diff --git a/test/services/LicenseServiceTest.js b/test/services/LicenseServiceTest.js index 740df6d..8107e59 100644 --- a/test/services/LicenseServiceTest.js +++ b/test/services/LicenseServiceTest.js @@ -14,6 +14,7 @@ import LicenseTemplateService from '../../src/services/LicenseTemplateService'; import LicenseeService from '../../src/services/LicenseeService'; import LicenseService from '../../src/services/LicenseService'; import Constants from '../../src/Constants'; +import Service from '../../src/services/Service'; describe('services.LicenseServiceTest', () => { let context; @@ -231,6 +232,19 @@ describe('services.LicenseServiceTest', () => { })); }); + it('check "filter" in list method', () => + // test + // if filter parameter is object + LicenseService.list(context, { page: 2, items: 10 }) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=2;items=10'); + }) + // if filter parameter is string + .then(() => LicenseService.list(context, 'page=3;items=20')) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=3;items=20'); + })); + it('check "update" method', () => { const product = new Product() .setProperty('number', Faker.string('JS-TEST-').toUpperCase()) diff --git a/test/services/LicenseTemplateServiceTest.js b/test/services/LicenseTemplateServiceTest.js index 04ad616..25532f2 100644 --- a/test/services/LicenseTemplateServiceTest.js +++ b/test/services/LicenseTemplateServiceTest.js @@ -9,6 +9,7 @@ import ProductService from '../../src/services/ProductService'; import ProductModuleService from '../../src/services/ProductModuleService'; import LicenseTemplateService from '../../src/services/LicenseTemplateService'; import Constants from '../../src/Constants'; +import Service from '../../src/services/Service'; describe('services.LicenseTemplateServiceTest', () => { @@ -202,6 +203,19 @@ describe('services.LicenseTemplateServiceTest', () => { })); }); + it('check "filter" in list method', () => + // test + // if filter parameter is object + LicenseTemplateService.list(context, { page: 2, items: 10 }) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=2;items=10'); + }) + // if filter parameter is string + .then(() => LicenseTemplateService.list(context, 'page=3;items=20')) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=3;items=20'); + })); + it('check "update" method', () => { const product = new Product() .setProperty('number', Faker.string('JS-TEST-').toUpperCase()) diff --git a/test/services/LicenseeServiceTest.js b/test/services/LicenseeServiceTest.js index 019b0c6..70e4e43 100644 --- a/test/services/LicenseeServiceTest.js +++ b/test/services/LicenseeServiceTest.js @@ -159,6 +159,19 @@ describe('services.LicenseeServiceTest', () => { })); }); + it('check "filter" in list method', () => + // test + // if filter parameter is object + LicenseeService.list(context, { page: 2, items: 10 }) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=2;items=10'); + }) + // if filter parameter is string + .then(() => LicenseeService.list(context, 'page=3;items=20')) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=3;items=20'); + })); + it('check "update" method', () => { const product = new Product() .setProperty('number', Faker.string('JS-TEST-').toUpperCase()) diff --git a/test/services/ProductModuleServiceTest.js b/test/services/ProductModuleServiceTest.js index 779d0e5..dc0f699 100644 --- a/test/services/ProductModuleServiceTest.js +++ b/test/services/ProductModuleServiceTest.js @@ -7,6 +7,7 @@ import ProductModule from '../../src/entities/ProductModule'; import ProductService from '../../src/services/ProductService'; import ProductModuleService from '../../src/services/ProductModuleService'; import Constants from '../../src/Constants'; +import Service from '../../src/services/Service'; describe('services.ProductModuleServiceTest', () => { let context; @@ -161,6 +162,19 @@ describe('services.ProductModuleServiceTest', () => { })); }); + it('check "filter" in list method', () => + // test + // if filter parameter is object + ProductModuleService.list(context, { page: 2, items: 10 }) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=2;items=10'); + }) + // if filter parameter is string + .then(() => ProductModuleService.list(context, 'page=3;items=20')) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=3;items=20'); + })); + it('check "update" method', () => { const product = new Product() .setProperty('number', Faker.string('JS-TEST-').toUpperCase()) diff --git a/test/services/ProductServiceTest.js b/test/services/ProductServiceTest.js index 14ab521..7b35d69 100644 --- a/test/services/ProductServiceTest.js +++ b/test/services/ProductServiceTest.js @@ -6,6 +6,7 @@ import Product from '../../src/entities/Product'; import ProductDiscount from '../../src/entities/ProductDiscount'; import ProductService from '../../src/services/ProductService'; import Constants from '../../src/Constants'; +import Service from '../../src/services/Service'; describe('services.ProductServiceTest', () => { @@ -165,6 +166,19 @@ describe('services.ProductServiceTest', () => { })); }); + it('check "filter parameter in list" method', () => + // test + // if filter parameter is object + ProductService.list(context, { page: 2, items: 10 }) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=2;items=10'); + }) + // if filter parameter is string + .then(() => ProductService.list(context, 'page=3;items=20')) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=3;items=20'); + })); + it('check "update" method', () => { const product = new Product() .setProperty('number', Faker.string('JS-TEST-').toUpperCase()) diff --git a/test/services/TokenServiceTest.js b/test/services/TokenServiceTest.js index d5b1a0a..9873e1d 100644 --- a/test/services/TokenServiceTest.js +++ b/test/services/TokenServiceTest.js @@ -9,6 +9,7 @@ import ProductService from '../../src/services/ProductService'; import LicenseeService from '../../src/services/LicenseeService'; import TokenService from '../../src/services/TokenService'; import Constants from '../../src/Constants'; +import Service from '../../src/services/Service'; describe('services.TokenServiceTest', () => { @@ -173,6 +174,19 @@ describe('services.TokenServiceTest', () => { })); }); + it('check "filter" in list method', () => + // test + // if filter parameter is object + TokenService.list(context, { page: 2, items: 10 }) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=2;items=10'); + }) + // if filter parameter is string + .then(() => TokenService.list(context, 'page=3;items=20')) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=3;items=20'); + })); + it('check "delete" method', () => { const product = new Product() .setProperty('number', Faker.string('JS-TEST-').toUpperCase()) diff --git a/test/services/TransactionServiceTest.js b/test/services/TransactionServiceTest.js index a20408d..342bcab 100644 --- a/test/services/TransactionServiceTest.js +++ b/test/services/TransactionServiceTest.js @@ -2,6 +2,7 @@ import Faker from '../../test/Faker'; import Context from '../../src/vo/Context'; import Transaction from '../../src/entities/Transaction'; import TransactionService from '../../src/services/TransactionService'; +import Service from '../../src/services/Service'; describe('services.TransactionServiceTest', () => { @@ -58,6 +59,19 @@ describe('services.TransactionServiceTest', () => { }); }); + it('check "filter" in list method', () => + // test + // if filter parameter is object + TransactionService.list(context, { page: 2, items: 10 }) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=2;items=10'); + }) + // if filter parameter is string + .then(() => TransactionService.list(context, 'page=3;items=20')) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=3;items=20'); + })); + it('check "update" method', () => { const transaction = new Transaction() .setProperty('number', Faker.string('JS-TEST-').toUpperCase()) diff --git a/test/services/UtilityServiceTest.js b/test/services/UtilityServiceTest.js index e5afba8..6fc473d 100644 --- a/test/services/UtilityServiceTest.js +++ b/test/services/UtilityServiceTest.js @@ -1,6 +1,7 @@ import Context from '../../src/vo/Context'; import Country from '../../src/entities/Country'; import UtilityService from '../../src/services/UtilityService'; +import Service from '../../src/services/Service'; describe('services.UtilityServiceTest', () => { @@ -29,4 +30,17 @@ describe('services.UtilityServiceTest', () => { expect(listCountries.length).toBeGreaterThanOrEqual(0); expect(listCountries[0] instanceof Country).toBe(true); })); + + it('check "filter" in listCountries method', () => + // test + // if filter parameter is object + UtilityService.listCountries(context, { page: 2, items: 10 }) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=2;items=10'); + }) + // if filter parameter is string + .then(() => UtilityService.listCountries(context, 'page=3;items=20')) + .then(() => { + expect(Service.getLastHttpRequestInfo().config.params.filter).toBe('page=3;items=20'); + })); });