{"action":"created","comment":{"url":"https://api.github.com/repos/SitePen/dstore/pulls/comments/37308163","id":37308163,"diff_hunk":"@@ -0,0 +1,391 @@\n+import { Handle, Hash } from 'dojo-core/interfaces';\n+import * as lang from 'dojo-core/lang';\n+import Promise from 'dojo-core/Promise';\n+import request, { providerRegistry, RequestOptions } from 'dojo-core/request';\n+import UrlSearchParams from 'dojo-core/UrlSearchParams';\n+import registerSuite = require('intern!object');\n+import assert = require('intern/chai!assert');\n+import * as dstore from 'src/interfaces';\n+import Request, { RequestStoreArgs } from 'src/Request';\n+import * as mockRequestProvider from './mockRequestProvider';\n+\n+class Model {\n+\tconstructor(args?: {}) {\n+\t\tlang.mixin(this, {\n+\t\t\t_restore: function (Constructor: { new (arg: any): { restored: boolean } }) {\n+\t\t\t\t// use constructor based restoration\n+\t\t\t\tconst restored = new Constructor(this);\n+\t\t\t\trestored.restored = true;\n+\t\t\t\treturn restored;\n+\t\t\t},\n+\t\t\tcreateSubclass: null\n+\t\t}, args);\n+\t}\n+\n+\t_restore(Constructor: { new (arg: any): { restored: boolean } }) {\n+\t\t// use constructor based restoration\n+\t\tconst restored = new Constructor(this);\n+\t\trestored.restored = true;\n+\t\treturn restored;\n+\t}\n+\n+\tname: string;\n+\n+\tdescribe() {\n+\t\treturn 'name is ' + this.name;\n+\t}\n+}\n+\n+\n+class ConcreteRequest<T> extends Request<T> {\n+\tadd(object: any, directives?: dstore.PutDirectives):  any {\n+\t\tthrow new Error('This Method is abstract');\n+\t}\n+\n+\tget(id: string | number): Promise<T> | void {\n+\t\tthrow new Error('This Method is abstract');\n+\t}\n+\n+\tput(object: T, directives?: dstore.PutDirectives):  Promise<T> {\n+\t\treturn new Promise(function (resolve) {\n+\t\t\tresolve(object)\n+\t\t});\n+\t}\n+\n+\tremove(id: any): Promise<T | void> {\n+\t\tthrow new Error('This Method is abstract');\n+\t}\n+}\n+\n+let store: ConcreteRequest<any>;\n+\n+const globalHeaders: { [ name: string ]: string } = {\n+\n+\t'test-global-header-a': 'true',\n+\t'test-global-header-b': 'yes'\n+};\n+const requestHeaders: { [ name: string ]: string } = {\n+\t'test-local-header-a': 'true',\n+\t'test-local-header-b': 'yes',\n+\t'test-override': 'overridden'\n+};\n+\n+function runCollectionTest<T>(collection: dstore.Collection<T>, rangeArgs: dstore.FetchRangeArgs | RequestOptions, expected?: RequestOptions) {\n+\tconst expectedResults: { [ name: string ]: number | string }[] = [\n+\t\t{ id: 1, name: 'one' },\n+\t\t{ id: 2, name: 'two' }\n+\t];\n+\tmockRequestProvider.setResponseText(JSON.stringify(expectedResults));\n+\tlet resultsPromise: dstore.FetchPromise<any>;\n+\tif (!expected) {\n+\t\texpected = <RequestOptions> rangeArgs;\n+\t\tresultsPromise = collection.fetch();\n+\t}\n+\telse {\n+\t\tconst { start, end } = <dstore.FetchRangeArgs> rangeArgs;\n+\t\tmockRequestProvider.setResponseHeaders({\n+\t\t\t'Content-Range': start + '-' + end + '/' + expectedResults.length\n+\t\t});\n+\t\tresultsPromise = collection.fetchRange(<dstore.FetchRangeArgs> rangeArgs);\n+\t}\n+\treturn resultsPromise.then(function (results) {\n+\t\texpected.headers && mockRequestProvider.assertRequestHeaders(expected.headers);\n+\t\texpected.query && mockRequestProvider.assertQuery(new UrlSearchParams(expected.query));\n+\n+\t\t// We cannot just assert deepEqual with results and expectedResults\n+\t\t// because the store converts results into model instances with additional members.\n+\t\tassert.strictEqual(results.length, expectedResults.length);\n+\t\tfor (let i = 0; i < results.length; ++i) {\n+\t\t\tconst result: { [ name: string ]: number | string } = results[i];\n+\t\t\tconst expectedResult: { [ name: string ]: number | string } = expectedResults[i];\n+\t\t\tfor (let key in expectedResult) {\n+\t\t\t\tassert.strictEqual(result[key], expectedResult[key]);\n+\t\t\t}\n+\t\t}\n+\t\tif (resultsPromise.totalLength instanceof Promise) {","path":"tests/unit/Request.ts","position":105,"original_position":105,"commit_id":"b27de882bfe6b8ffa016b643ad37733b42f7de97","original_commit_id":"b27de882bfe6b8ffa016b643ad37733b42f7de97","user":{"login":"kfranqueiro","id":398379,"avatar_url":"https://avatars.githubusercontent.com/u/398379?v=3","gravatar_id":"","url":"https://api.github.com/users/kfranqueiro","html_url":"https://github.com/kfranqueiro","followers_url":"https://api.github.com/users/kfranqueiro/followers","following_url":"https://api.github.com/users/kfranqueiro/following{/other_user}","gists_url":"https://api.github.com/users/kfranqueiro/gists{/gist_id}","starred_url":"https://api.github.com/users/kfranqueiro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kfranqueiro/subscriptions","organizations_url":"https://api.github.com/users/kfranqueiro/orgs","repos_url":"https://api.github.com/users/kfranqueiro/repos","events_url":"https://api.github.com/users/kfranqueiro/events{/privacy}","received_events_url":"https://api.github.com/users/kfranqueiro/received_events","type":"User","site_admin":false},"body":"Shouldn't this always be present and always a promise?  (Is this something to do with the mocks?)","created_at":"2015-08-18T14:57:06Z","updated_at":"2015-08-18T14:57:06Z","html_url":"https://github.com/SitePen/dstore/pull/145#discussion_r37308163","pull_request_url":"https://api.github.com/repos/SitePen/dstore/pulls/145","_links":{"self":{"href":"https://api.github.com/repos/SitePen/dstore/pulls/comments/37308163"},"html":{"href":"https://github.com/SitePen/dstore/pull/145#discussion_r37308163"},"pull_request":{"href":"https://api.github.com/repos/SitePen/dstore/pulls/145"}}},"pull_request":{"url":"https://api.github.com/repos/SitePen/dstore/pulls/145","id":40867395,"html_url":"https://github.com/SitePen/dstore/pull/145","diff_url":"https://github.com/SitePen/dstore/pull/145.diff","patch_url":"https://github.com/SitePen/dstore/pull/145.patch","issue_url":"https://api.github.com/repos/SitePen/dstore/issues/145","number":145,"state":"open","locked":false,"title":"Convert several modules to TypeScript","user":{"login":"maier49","id":5474358,"avatar_url":"https://avatars.githubusercontent.com/u/5474358?v=3","gravatar_id":"","url":"https://api.github.com/users/maier49","html_url":"https://github.com/maier49","followers_url":"https://api.github.com/users/maier49/followers","following_url":"https://api.github.com/users/maier49/following{/other_user}","gists_url":"https://api.github.com/users/maier49/gists{/gist_id}","starred_url":"https://api.github.com/users/maier49/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maier49/subscriptions","organizations_url":"https://api.github.com/users/maier49/orgs","repos_url":"https://api.github.com/users/maier49/repos","events_url":"https://api.github.com/users/maier49/events{/privacy}","received_events_url":"https://api.github.com/users/maier49/received_events","type":"User","site_admin":false},"body":"Fixes #143, Fixes #138, Fixes #137, Fixes #136\r\n\r\n * QueryResults has been converted to TypeScript\r\n * Filter has been converted to TypeScript\r\n * Store and tests/unit/Store have been converted.\r\n * Request and tests/unit/Request have been converted.\r\n\r\nAll test cases that were previously passing are still\r\npassing, as well as the Request test cases.\r\n\r\nQueryResults needed to be modified to return an ES6 style\r\npromise, because of calls to super made by the promise\r\nreturned from dojo-core/Request. This conversion in turn\r\nrequired many tests cases and some sources files to be\r\nupdated, as they were relying on the fact that Dojo 1 style\r\npromises execute synchronously in some cases.","created_at":"2015-07-27T03:15:31Z","updated_at":"2015-08-18T14:57:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ddc07f1e2cab2fb4f0419f7d077911c62ef1b926","assignee":{"login":"kfranqueiro","id":398379,"avatar_url":"https://avatars.githubusercontent.com/u/398379?v=3","gravatar_id":"","url":"https://api.github.com/users/kfranqueiro","html_url":"https://github.com/kfranqueiro","followers_url":"https://api.github.com/users/kfranqueiro/followers","following_url":"https://api.github.com/users/kfranqueiro/following{/other_user}","gists_url":"https://api.github.com/users/kfranqueiro/gists{/gist_id}","starred_url":"https://api.github.com/users/kfranqueiro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kfranqueiro/subscriptions","organizations_url":"https://api.github.com/users/kfranqueiro/orgs","repos_url":"https://api.github.com/users/kfranqueiro/repos","events_url":"https://api.github.com/users/kfranqueiro/events{/privacy}","received_events_url":"https://api.github.com/users/kfranqueiro/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/SitePen/dstore/pulls/145/commits","review_comments_url":"https://api.github.com/repos/SitePen/dstore/pulls/145/comments","review_comment_url":"https://api.github.com/repos/SitePen/dstore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SitePen/dstore/issues/145/comments","statuses_url":"https://api.github.com/repos/SitePen/dstore/statuses/b27de882bfe6b8ffa016b643ad37733b42f7de97","head":{"label":"maier49:convert-request-to-ts","ref":"convert-request-to-ts","sha":"b27de882bfe6b8ffa016b643ad37733b42f7de97","user":{"login":"maier49","id":5474358,"avatar_url":"https://avatars.githubusercontent.com/u/5474358?v=3","gravatar_id":"","url":"https://api.github.com/users/maier49","html_url":"https://github.com/maier49","followers_url":"https://api.github.com/users/maier49/followers","following_url":"https://api.github.com/users/maier49/following{/other_user}","gists_url":"https://api.github.com/users/maier49/gists{/gist_id}","starred_url":"https://api.github.com/users/maier49/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maier49/subscriptions","organizations_url":"https://api.github.com/users/maier49/orgs","repos_url":"https://api.github.com/users/maier49/repos","events_url":"https://api.github.com/users/maier49/events{/privacy}","received_events_url":"https://api.github.com/users/maier49/received_events","type":"User","site_admin":false},"repo":{"id":38319671,"name":"dstore","full_name":"maier49/dstore","owner":{"login":"maier49","id":5474358,"avatar_url":"https://avatars.githubusercontent.com/u/5474358?v=3","gravatar_id":"","url":"https://api.github.com/users/maier49","html_url":"https://github.com/maier49","followers_url":"https://api.github.com/users/maier49/followers","following_url":"https://api.github.com/users/maier49/following{/other_user}","gists_url":"https://api.github.com/users/maier49/gists{/gist_id}","starred_url":"https://api.github.com/users/maier49/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maier49/subscriptions","organizations_url":"https://api.github.com/users/maier49/orgs","repos_url":"https://api.github.com/users/maier49/repos","events_url":"https://api.github.com/users/maier49/events{/privacy}","received_events_url":"https://api.github.com/users/maier49/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maier49/dstore","description":"","fork":true,"url":"https://api.github.com/repos/maier49/dstore","forks_url":"https://api.github.com/repos/maier49/dstore/forks","keys_url":"https://api.github.com/repos/maier49/dstore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maier49/dstore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maier49/dstore/teams","hooks_url":"https://api.github.com/repos/maier49/dstore/hooks","issue_events_url":"https://api.github.com/repos/maier49/dstore/issues/events{/number}","events_url":"https://api.github.com/repos/maier49/dstore/events","assignees_url":"https://api.github.com/repos/maier49/dstore/assignees{/user}","branches_url":"https://api.github.com/repos/maier49/dstore/branches{/branch}","tags_url":"https://api.github.com/repos/maier49/dstore/tags","blobs_url":"https://api.github.com/repos/maier49/dstore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maier49/dstore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maier49/dstore/git/refs{/sha}","trees_url":"https://api.github.com/repos/maier49/dstore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maier49/dstore/statuses/{sha}","languages_url":"https://api.github.com/repos/maier49/dstore/languages","stargazers_url":"https://api.github.com/repos/maier49/dstore/stargazers","contributors_url":"https://api.github.com/repos/maier49/dstore/contributors","subscribers_url":"https://api.github.com/repos/maier49/dstore/subscribers","subscription_url":"https://api.github.com/repos/maier49/dstore/subscription","commits_url":"https://api.github.com/repos/maier49/dstore/commits{/sha}","git_commits_url":"https://api.github.com/repos/maier49/dstore/git/commits{/sha}","comments_url":"https://api.github.com/repos/maier49/dstore/comments{/number}","issue_comment_url":"https://api.github.com/repos/maier49/dstore/issues/comments{/number}","contents_url":"https://api.github.com/repos/maier49/dstore/contents/{+path}","compare_url":"https://api.github.com/repos/maier49/dstore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maier49/dstore/merges","archive_url":"https://api.github.com/repos/maier49/dstore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maier49/dstore/downloads","issues_url":"https://api.github.com/repos/maier49/dstore/issues{/number}","pulls_url":"https://api.github.com/repos/maier49/dstore/pulls{/number}","milestones_url":"https://api.github.com/repos/maier49/dstore/milestones{/number}","notifications_url":"https://api.github.com/repos/maier49/dstore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maier49/dstore/labels{/name}","releases_url":"https://api.github.com/repos/maier49/dstore/releases{/id}","created_at":"2015-06-30T16:14:31Z","updated_at":"2015-06-30T16:14:31Z","pushed_at":"2015-08-14T22:24:48Z","git_url":"git://github.com/maier49/dstore.git","ssh_url":"git@github.com:maier49/dstore.git","clone_url":"https://github.com/maier49/dstore.git","svn_url":"https://github.com/maier49/dstore","homepage":"http://dstorejs.io/","size":1419,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"SitePen:master","ref":"master","sha":"6a161bd6947ab2b1e346ade78a1547136d244b8f","user":{"login":"SitePen","id":1067343,"avatar_url":"https://avatars.githubusercontent.com/u/1067343?v=3","gravatar_id":"","url":"https://api.github.com/users/SitePen","html_url":"https://github.com/SitePen","followers_url":"https://api.github.com/users/SitePen/followers","following_url":"https://api.github.com/users/SitePen/following{/other_user}","gists_url":"https://api.github.com/users/SitePen/gists{/gist_id}","starred_url":"https://api.github.com/users/SitePen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SitePen/subscriptions","organizations_url":"https://api.github.com/users/SitePen/orgs","repos_url":"https://api.github.com/users/SitePen/repos","events_url":"https://api.github.com/users/SitePen/events{/privacy}","received_events_url":"https://api.github.com/users/SitePen/received_events","type":"Organization","site_admin":false},"repo":{"id":11800427,"name":"dstore","full_name":"SitePen/dstore","owner":{"login":"SitePen","id":1067343,"avatar_url":"https://avatars.githubusercontent.com/u/1067343?v=3","gravatar_id":"","url":"https://api.github.com/users/SitePen","html_url":"https://github.com/SitePen","followers_url":"https://api.github.com/users/SitePen/followers","following_url":"https://api.github.com/users/SitePen/following{/other_user}","gists_url":"https://api.github.com/users/SitePen/gists{/gist_id}","starred_url":"https://api.github.com/users/SitePen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SitePen/subscriptions","organizations_url":"https://api.github.com/users/SitePen/orgs","repos_url":"https://api.github.com/users/SitePen/repos","events_url":"https://api.github.com/users/SitePen/events{/privacy}","received_events_url":"https://api.github.com/users/SitePen/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SitePen/dstore","description":"","fork":false,"url":"https://api.github.com/repos/SitePen/dstore","forks_url":"https://api.github.com/repos/SitePen/dstore/forks","keys_url":"https://api.github.com/repos/SitePen/dstore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SitePen/dstore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SitePen/dstore/teams","hooks_url":"https://api.github.com/repos/SitePen/dstore/hooks","issue_events_url":"https://api.github.com/repos/SitePen/dstore/issues/events{/number}","events_url":"https://api.github.com/repos/SitePen/dstore/events","assignees_url":"https://api.github.com/repos/SitePen/dstore/assignees{/user}","branches_url":"https://api.github.com/repos/SitePen/dstore/branches{/branch}","tags_url":"https://api.github.com/repos/SitePen/dstore/tags","blobs_url":"https://api.github.com/repos/SitePen/dstore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SitePen/dstore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SitePen/dstore/git/refs{/sha}","trees_url":"https://api.github.com/repos/SitePen/dstore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SitePen/dstore/statuses/{sha}","languages_url":"https://api.github.com/repos/SitePen/dstore/languages","stargazers_url":"https://api.github.com/repos/SitePen/dstore/stargazers","contributors_url":"https://api.github.com/repos/SitePen/dstore/contributors","subscribers_url":"https://api.github.com/repos/SitePen/dstore/subscribers","subscription_url":"https://api.github.com/repos/SitePen/dstore/subscription","commits_url":"https://api.github.com/repos/SitePen/dstore/commits{/sha}","git_commits_url":"https://api.github.com/repos/SitePen/dstore/git/commits{/sha}","comments_url":"https://api.github.com/repos/SitePen/dstore/comments{/number}","issue_comment_url":"https://api.github.com/repos/SitePen/dstore/issues/comments{/number}","contents_url":"https://api.github.com/repos/SitePen/dstore/contents/{+path}","compare_url":"https://api.github.com/repos/SitePen/dstore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SitePen/dstore/merges","archive_url":"https://api.github.com/repos/SitePen/dstore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SitePen/dstore/downloads","issues_url":"https://api.github.com/repos/SitePen/dstore/issues{/number}","pulls_url":"https://api.github.com/repos/SitePen/dstore/pulls{/number}","milestones_url":"https://api.github.com/repos/SitePen/dstore/milestones{/number}","notifications_url":"https://api.github.com/repos/SitePen/dstore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SitePen/dstore/labels{/name}","releases_url":"https://api.github.com/repos/SitePen/dstore/releases{/id}","created_at":"2013-07-31T20:24:42Z","updated_at":"2015-08-13T20:37:28Z","pushed_at":"2015-08-14T22:28:32Z","git_url":"git://github.com/SitePen/dstore.git","ssh_url":"git@github.com:SitePen/dstore.git","clone_url":"https://github.com/SitePen/dstore.git","svn_url":"https://github.com/SitePen/dstore","homepage":"http://dstorejs.io/","size":3294,"stargazers_count":207,"watchers_count":207,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":45,"mirror_url":null,"open_issues_count":38,"forks":45,"open_issues":38,"watchers":207,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SitePen/dstore/pulls/145"},"html":{"href":"https://github.com/SitePen/dstore/pull/145"},"issue":{"href":"https://api.github.com/repos/SitePen/dstore/issues/145"},"comments":{"href":"https://api.github.com/repos/SitePen/dstore/issues/145/comments"},"review_comments":{"href":"https://api.github.com/repos/SitePen/dstore/pulls/145/comments"},"review_comment":{"href":"https://api.github.com/repos/SitePen/dstore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SitePen/dstore/pulls/145/commits"},"statuses":{"href":"https://api.github.com/repos/SitePen/dstore/statuses/b27de882bfe6b8ffa016b643ad37733b42f7de97"}}}}