Test to prove sorting by integer works

This commit is contained in:
sharpshark28 2017-08-17 18:13:49 -05:00
parent a10ac23e1a
commit 6364d326cd
3 changed files with 21 additions and 2 deletions

View file

@ -34,8 +34,6 @@ Currently supports booleans and strings. (See [#1](https://github.com/sharpshark
#### Sort
Currently supports booleans and strings. (See [#1](https://github.com/sharpshark28/json-query-chain/issues/2) for Integer Support)
##### By Boolean
```javascript
@ -48,6 +46,12 @@ Currently supports booleans and strings. (See [#1](https://github.com/sharpshark
.sort('name')
```
##### By Number
```javascript
.sort('netWorth')
```
#### Pagination
Page 1 with 5 results per page.

View file

@ -58,6 +58,16 @@ test('should sort by boolean isActive', () => {
expect(query[0].name).toBe('Katelyn Steele');
});
test('should sort by number netWorth', () => {
let query = new Query(TestData)
.sort('netWorth')
.results;
expect(query[0].name).toBe('Howard Buckley'); // Negative
expect(query[1].name).toBe('Natalia Petty'); // 0
expect(query[query.length - 1].name).toBe('Newman Mays'); // Richest
});
test('should sort by string name', () => {
let query = new Query(TestData)
.sort('name')

View file

@ -3,6 +3,7 @@
"_id": "5928038b69b33613f3577487",
"isActive": true,
"age": 20,
"netWorth": 54200.49,
"name": "Haynes Meadows",
"tags": [
"et",
@ -18,6 +19,7 @@
"_id": "5928038ba2400e7e09550991",
"isActive": false,
"age": 22,
"netWorth": 11900,
"name": "Katelyn Steele",
"tags": [
"cupidatat",
@ -33,6 +35,7 @@
"_id": "5928038bff4df5c29016be22",
"isActive": false,
"age": 29,
"netWorth": 0,
"name": "Natalia Petty",
"tags": [
"nulla",
@ -48,6 +51,7 @@
"_id": "5928038b496f64e646cb8d69",
"isActive": false,
"age": 34,
"netWorth": -5000.2,
"name": "Howard Buckley",
"tags": [
"qui",
@ -63,6 +67,7 @@
"_id": "5928038b4d214186ba1e7fa2",
"isActive": false,
"age": 22,
"netWorth": 401512.99,
"name": "Jenkins Mosley",
"tags": [
"adipisicing",