Add tests for new call route type definition

This commit is contained in:
David Gee
2017-03-20 18:44:40 -05:00
parent f94da7c86d
commit 62057d84c8
2 changed files with 75 additions and 1 deletions
+74
View File
@@ -2,6 +2,7 @@
import falcor = require('falcor');
import Router = require('falcor-router');
import falcorJsonGraph = require('falcor-json-graph');
new Router([]);
new Router([], {});
@@ -100,3 +101,76 @@ new Router([{
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return {path: 'json.todosById.1234.name', value: 'Buy cheese'};
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return falcorJsonGraph.pathInvalidation('json.todos.length');
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return [
falcorJsonGraph.pathInvalidation('json.todos.length'),
{path: 'json.todosById.1234.name', value: 'Buy cheese'}
]
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return new Promise((resolve, reject): void => {
resolve([
falcorJsonGraph.pathInvalidation('json.todos.length'),
{path: 'json.todosById.1234.name', value: 'Buy cheese'}
]);
});
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return {
paths: [['json', 'todosById', '1234', 'name']],
jsonGraph: {
json: {
todosById: {
1234: {
name: 'Buy cheese'
}
}
}
}
};
}
}]);
new Router([{
route: 'todos.new',
call(callpath, args) {
return new Promise((resolve, reject): void => {
resolve({
paths: [['json', 'todosById', '1234', 'name']],
jsonGraph: {
json: {
todosById: {
1234: {
name: 'Buy cheese'
}
}
}
}
});
});
}
}]);
+1 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for falcor-router 0.4.0
// Project: https://github.com/Netflix/falcor-router
// Definitions by: Quramy <https://github.com/Quramy/>
// Definitions by: Quramy <https://github.com/Quramy/> and cdhgee <https://github.com/cdhgee/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference types="falcor" />