2016-08-06 01:47:31 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-08-08 12:10:14 +03:00
|
|
|
const Odata = require('../index');
|
2016-08-06 01:47:31 +03:00
|
|
|
|
|
|
|
const config = {
|
|
|
|
service: 'https://example.com',
|
|
|
|
resources: 'Customers'
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('orderby tests', function() {
|
|
|
|
|
|
|
|
var odata;
|
|
|
|
beforeEach(function() {
|
|
|
|
odata = Odata(config);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should order Customers resource by balance', function() {
|
2016-08-06 17:51:55 +03:00
|
|
|
expect(odata.orderby('balance').query()).toEqual('https://example.com/Customers?%24orderby=balance');
|
2016-08-06 01:47:31 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should order Customers resource by balance ascending', function() {
|
2016-08-06 17:51:55 +03:00
|
|
|
expect(odata.orderby('balance', 'asc').query()).toEqual('https://example.com/Customers?%24orderby=balance%20asc');
|
2016-08-06 01:47:31 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should order Customers resource by balance descending', function() {
|
2016-08-06 17:51:55 +03:00
|
|
|
expect(odata.orderby('balance', 'desc').query()).toEqual('https://example.com/Customers?%24orderby=balance%20desc');
|
2016-08-06 01:47:31 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should order Customers resource by balance descending', function() {
|
2016-08-06 17:51:55 +03:00
|
|
|
expect(odata.orderby(['balance', 'desc']).query()).toEqual('https://example.com/Customers?%24orderby=balance%20desc');
|
2016-08-06 01:47:31 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should order Customers resource by PriceGroup then balance descending', function() {
|
2016-08-06 17:51:55 +03:00
|
|
|
expect(odata.orderby(['PriceGroup'], ['balance', 'desc']).query())
|
2016-08-06 01:47:31 +03:00
|
|
|
.toEqual('https://example.com/Customers?%24orderby=PriceGroup%2Cbalance%20desc');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should order Customers resource by PriceGroup then balance descending (method 2)', function() {
|
2016-08-06 17:51:55 +03:00
|
|
|
expect(odata.orderby('PriceGroup').orderby(['balance', 'desc']).query())
|
2016-08-06 01:47:31 +03:00
|
|
|
.toEqual('https://example.com/Customers?%24orderby=PriceGroup%2Cbalance%20desc');
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|