-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add test with mocha - Add webpack test browser - Update tsconfig to generate typings
- Loading branch information
Showing
13 changed files
with
123 additions
and
268 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Queryable } from "../dist"; | ||
import { nations, players, continents } from "./source"; | ||
import { expect } from "chai"; | ||
|
||
describe('join', () => { | ||
const query = Queryable.from(players) | ||
.join(nations, (x, y) => x.nationId === y.id) | ||
|
||
it('can run', () => { | ||
query.toList().then(data => { | ||
expect(data).not.equal(undefined); | ||
}); | ||
}); | ||
|
||
it('put out {x,y} object have value', () => { | ||
query.toList().then(data => { | ||
expect(data[0].x).not.equal(undefined); | ||
expect(data[0].y).not.equal(undefined); | ||
expect(data[0].y).not.equal(null); | ||
expect(data[0].y).not.equal(null); | ||
}); | ||
}); | ||
|
||
it('cannot over original length', () => { | ||
Promise.all([query.toList(), players]).then((arr: any[]) => { | ||
expect(arr[0].length).not.greaterThan(arr[1].length); | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Queryable } from "../dist"; | ||
import { nations, players, continents } from "./source"; | ||
import { expect } from "chai"; | ||
|
||
describe('leftJoin', () => { | ||
const query = Queryable.from(players) | ||
.leftJoin(nations, (x, y) => x.nationId === y.id); | ||
|
||
it('can run', () => { | ||
query.toList().then(data => { | ||
expect(data).not.equal(undefined); | ||
}); | ||
}); | ||
|
||
it('all properties in new object is inside input object properties', () => { | ||
Promise.all([query.toList(), players, nations]).then((arr: any[]) => { | ||
const arr0Keys = Object.keys(arr[0][0]); | ||
const arr1Keys = Object.keys(arr[1][0]); | ||
const arr2Keys = Object.keys(arr[2][0]); | ||
|
||
arr1Keys.forEach(p => { | ||
expect(arr0Keys.includes(p)).to.equal(true); | ||
}) | ||
|
||
arr2Keys.forEach(p => { | ||
expect(arr0Keys.includes(p)).to.equal(true); | ||
}) | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { players, continents, nations } from './source'; | ||
import { expect } from 'chai'; | ||
import { Queryable } from '../dist'; | ||
|
||
describe('selectMany', () => { | ||
const query = Queryable.from(players) | ||
.selectMany(x => x.skills); | ||
|
||
it('is fatten list (this case is number)', async () => { | ||
const data: any[] = await query.toList(); | ||
data.forEach(item => { | ||
expect(Number.isInteger(item)).to.equal(true) | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export let players = new Promise<{ name, overall, nationId, skills }[]>((resolve, reject) => { | ||
// skills: attack, stamia, speed, shoot | ||
setTimeout(() => { | ||
resolve([ | ||
{ name: 'Ronaldo', overall: 96, nationId: 1, skills: [96, 85, 87, 91] }, | ||
{ name: 'Messi', overall: 98, nationId: 2, skills: [97, 85, 91, 93] }, | ||
{ name: 'Mbappe', overall: 86, nationId: 3, skills: [89, 81, 95, 83] }, | ||
{ name: 'Matial', overall: 81, nationId: 3, skills: [81, 80, 89, 81] }, | ||
{ name: 'Salah', overall: 89, nationId: 4, skills: [88, 82, 97, 86] } | ||
]); | ||
}, 1000); | ||
}) | ||
|
||
export let nations = new Promise<{ id, name, areaId }[]>(resolve => { | ||
setTimeout(() => { | ||
resolve([ | ||
{ id: 1, name: 'Portugal', areaId: 1 }, | ||
{ id: 2, name: 'Argentina', areaId: 2 }, | ||
{ id: 3, name: 'France', areaId: 1 }, | ||
{ id: 4, name: 'Egypt', areaId: 3 } | ||
]); | ||
}, 2000); | ||
}) | ||
|
||
export let continents = new Promise<{ id, areaName }[]>(resolve => { | ||
setTimeout(() => { | ||
resolve([ | ||
{ id: 1, areaName: 'Euro' }, | ||
{ id: 2, areaName: 'South America' }, | ||
]); | ||
}, 2300); | ||
}) |
Oops, something went wrong.