Skip to content

Commit

Permalink
Add test for filter parameter in list methods
Browse files Browse the repository at this point in the history
  • Loading branch information
v-rudkovskiy committed Mar 27, 2018
1 parent 553c43e commit 2439363
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/services/LicenseServiceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down
14 changes: 14 additions & 0 deletions test/services/LicenseTemplateServiceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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())
Expand Down
13 changes: 13 additions & 0 deletions test/services/LicenseeServiceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
14 changes: 14 additions & 0 deletions test/services/ProductModuleServiceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down
14 changes: 14 additions & 0 deletions test/services/ProductServiceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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())
Expand Down
14 changes: 14 additions & 0 deletions test/services/TokenServiceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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())
Expand Down
14 changes: 14 additions & 0 deletions test/services/TransactionServiceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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())
Expand Down
14 changes: 14 additions & 0 deletions test/services/UtilityServiceTest.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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');
}));
});

0 comments on commit 2439363

Please sign in to comment.