odata-client/spec/order_spec.js

45 строки
1.5 KiB
JavaScript
Исходник Постоянная ссылка Обычный вид История

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() {
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() {
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() {
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() {
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() {
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() {
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');
});
});