{"_id":"fh-mocks","_rev":"26-2fa9b6a6dd5f5b9e366ba31d21a754b8","name":"fh-mocks","description":"Mocks for the fh-js-sdk to enable unit testing of application logic.","dist-tags":{"latest":"0.1.1"},"versions":{"0.0.0":{"name":"fh-mocks","version":"0.0.0","description":"Mocks for the fh-js-sdk to enable unit testing of application logic.","main":"./lib/api.js","scripts":{"test":"make test"},"keywords":["fh","fh-js-sdk","fh-mocks","mocks"],"author":{"name":"Evan Shortiss"},"license":"Copyright (c) 2014 FeedHenry Ltd, All Rights Reserved.","devDependencies":{"linelint":"0.0.3","lintspaces-cli":"0.0.4","mocha":"~1.21.4","jshint":"~2.5.3","chai":"~1.9.1","sinon":"~1.10.3","browserify":"~5.10.0"},"_id":"fh-mocks@0.0.0","dist":{"shasum":"3217e921faab151370f62efd12337ea116e6ba62","tarball":"https://registry.npmjs.org/fh-mocks/-/fh-mocks-0.0.0.tgz","integrity":"sha512-Uef6NEK3/VjbtAqPx4Q9SSFFnbOPaiAM4HwXLcAmWCHGmQGMoUvelosisNrcjckuESSyduNLt0wCU+zEo3U0vA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCPLiVZ3u9Fzajep3Yu9iCLahNLQVNORGSvLRxyAOpe+gIhAJkpcH21AEc/bOYTcxPXaLu2yqI7cxB2BNkP4Trn5H2c"}]},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"evanshortiss","email":"evanshortiss@gmail.com"},"maintainers":[{"name":"evanshortiss","email":"evanshortiss@gmail.com"}]},"0.0.1":{"name":"fh-mocks","version":"0.0.1","description":"Mocks for the fh-js-sdk to enable unit testing of application logic.","main":"./lib/api.js","scripts":{"test":"make test"},"keywords":["fh","fh-js-sdk","fh-mocks","mocks"],"author":{"name":"Evan Shortiss"},"license":"Copyright (c) 2014 FeedHenry Ltd, All Rights Reserved.","devDependencies":{"linelint":"0.0.3","lintspaces-cli":"0.0.4","mocha":"~1.21.4","jshint":"~2.5.3","chai":"~1.9.1","sinon":"~1.10.3","browserify":"~5.10.0"},"_id":"fh-mocks@0.0.1","dist":{"shasum":"01e693b6559d3aaa5ab845fbf3585ebc18595a7a","tarball":"https://registry.npmjs.org/fh-mocks/-/fh-mocks-0.0.1.tgz","integrity":"sha512-71yzRuYWicpZOCFMxO+HpYPmDDYKsKNB1+viOr6HIrTywcabNBkFzxUklhj7yzQBtuVtdcRwrj1its6t0UiXXA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD66xiadaNksV+MTvB5cbxxoeX3IewpABI+xYe92OR88AIhAJtL3vVAUc3pDEYJ3ONlZkj5ZpEN+i2mtCb3MRYYaOZT"}]},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"evanshortiss","email":"evanshortiss@gmail.com"},"maintainers":[{"name":"evanshortiss","email":"evanshortiss@gmail.com"}]},"0.0.2":{"name":"fh-mocks","version":"0.0.2","description":"Mocks for the fh-js-sdk to enable unit testing of application logic.","main":"./lib/api.js","scripts":{"test":"make test"},"keywords":["fh","fh-js-sdk","fh-mocks","mocks"],"author":{"name":"Evan Shortiss"},"license":"Copyright (c) 2014 FeedHenry Ltd, All Rights Reserved.","devDependencies":{"linelint":"0.0.3","lintspaces-cli":"0.0.4","mocha":"~1.21.4","jshint":"~2.5.3","chai":"~1.9.1","sinon":"~1.10.3","browserify":"~5.10.0"},"_id":"fh-mocks@0.0.2","dist":{"shasum":"0941628333ad1fed4feb414b830e3891ceb911ab","tarball":"https://registry.npmjs.org/fh-mocks/-/fh-mocks-0.0.2.tgz","integrity":"sha512-CrZJwqOopI06xlul5bd8KGTE6iao4cEyI2HSxlU7lPAgMaiWQexlY5xpvI0XQVgVjhc6tnfax5nX8PHKwqMZKA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwmXxojFl0fEWjYXMrVsmaPax5cbfbYuntighWw3juawIhAL7WRbrTBL9mvUEf0QLl/wF20zIXTyrIF86UjiE+NZFK"}]},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"evanshortiss","email":"evanshortiss@gmail.com"},"maintainers":[{"name":"evanshortiss","email":"evanshortiss@gmail.com"}]},"0.0.3":{"name":"fh-mocks","version":"0.0.3","description":"Mocks for the fh-js-sdk to enable unit testing of application logic.","main":"./lib/api.js","scripts":{"test":"make test"},"keywords":["fh","fh-js-sdk","fh-mocks","mocks"],"author":{"name":"Evan Shortiss"},"license":"Copyright (c) 2014 FeedHenry Ltd, All Rights Reserved.","devDependencies":{"linelint":"0.0.3","lintspaces-cli":"0.0.4","mocha":"~1.21.4","jshint":"~2.5.3","chai":"~1.9.1","sinon":"~1.10.3","browserify":"~5.10.0"},"_id":"fh-mocks@0.0.3","dist":{"shasum":"73d88595f41331c5b424163227ed6e00bbe68a55","tarball":"https://registry.npmjs.org/fh-mocks/-/fh-mocks-0.0.3.tgz","integrity":"sha512-3kzNlRc2g9+Ing/V0ngQ/uJJh0IAIpkZgKINGxjtV9qe3orJ4lL3tZ7mG/uW5HoHTS4Zd2U3MwZn8uP0WlhQfQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAhwdByJUoSUbqaonBB31OFKHgSCwTOxYnHtV2sQT0FgAiEAgVdaST3VrdUvVfYbAcpxIlRaoEMt2r/R58cnB/Okk7U="}]},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"evanshortiss","email":"evanshortiss@gmail.com"},"maintainers":[{"name":"evanshortiss","email":"evanshortiss@gmail.com"}]},"0.0.4":{"name":"fh-mocks","version":"0.0.4","description":"Mocks for the fh-js-sdk to enable unit testing of application logic.","main":"./lib/api.js","scripts":{"test":"make test"},"keywords":["fh","fh-js-sdk","fh-mocks","mocks","feedhenry","unit","testing"],"author":{"name":"Evan Shortiss"},"license":"MIT","devDependencies":{"linelint":"0.0.3","lintspaces-cli":"0.0.4","mocha":"~1.21.4","jshint":"~2.5.3","chai":"~1.9.1","sinon":"~1.10.3","browserify":"~5.10.0","xtend":"~4.0.0"},"_id":"fh-mocks@0.0.4","dist":{"shasum":"61ebc8575d36a544a96322ba206d70a0349e59ec","tarball":"https://registry.npmjs.org/fh-mocks/-/fh-mocks-0.0.4.tgz","integrity":"sha512-abrsbNsLlTR6Xj8dTL7wmPspSCcb4dad04ri6n+ClJG9h8vAFQ3B6AQJCvkbryAKWtmm4jEtQCYkFYQ9F2F7cg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICltcxeVhPivwFKWy1kcnX1P+8fxUgwIk1N7ah/ujk9gAiEA/0BFLkTqk5ZnQa2oE3ddZpYZcnphUNOCKABKXNDjJVE="}]},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"evanshortiss","email":"evanshortiss@gmail.com"},"maintainers":[{"name":"evanshortiss","email":"evanshortiss@gmail.com"}]},"0.0.7":{"name":"fh-mocks","version":"0.0.7","description":"Mocks for the fh-js-sdk to enable unit testing of application logic.","main":"./lib/api.js","scripts":{"test":"make test"},"keywords":["fh","fh-js-sdk","fh-mocks","mocks","feedhenry","unit","testing"],"author":{"name":"Evan Shortiss"},"license":"MIT","devDependencies":{"linelint":"0.0.3","lintspaces-cli":"0.0.4","mocha":"~1.21.4","jshint":"~2.5.3","chai":"~1.9.1","sinon":"~1.10.3","browserify":"~5.10.0"},"dependencies":{"xtend":"~4.0.0"},"gitHead":"e053e104c0ba5fda5bbb0bab8477864cad80f082","_id":"fh-mocks@0.0.7","_shasum":"bf1c8697b4d1e5ab516d5619b6f27ac14a770504","_from":".","_npmVersion":"2.7.5","_nodeVersion":"0.10.24","_npmUser":{"name":"evanshortiss","email":"evanshortiss@gmail.com"},"maintainers":[{"name":"evanshortiss","email":"evanshortiss@gmail.com"}],"dist":{"shasum":"bf1c8697b4d1e5ab516d5619b6f27ac14a770504","tarball":"https://registry.npmjs.org/fh-mocks/-/fh-mocks-0.0.7.tgz","integrity":"sha512-1sPo99ZHns2BLKvI8rxpBbi7ZY1EhwsNStCiuprP7N/LLNPST3tpBBv8ZkgWny4ICuICPlAVw0Om1K73aFg6nA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFg5rc/jOgNzzA9VcNjJqpnGn+4kqmwJh5usISaTjNdNAiEAzzlUGdOrYOo/dTNBqV4KJrvbpPjrBHX8jfUTiycLT54="}]}},"0.0.10":{"name":"fh-mocks","version":"0.0.10","description":"Mocks for the fh-js-sdk to enable unit testing of application logic.","main":"./lib/api.js","scripts":{"test":"make test"},"keywords":["fh","fh-js-sdk","fh-mocks","mocks","feedhenry","unit","testing"],"author":{"name":"Evan Shortiss"},"license":"MIT","devDependencies":{"linelint":"0.0.3","lintspaces-cli":"0.0.4","mocha":"~1.21.4","jshint":"~2.5.3","chai":"~1.9.1","sinon":"~1.10.3","browserify":"~5.10.0"},"dependencies":{"xtend":"~4.0.0"},"gitHead":"8881a5d99234c6fa75289a4a1335086311c0b523","_id":"fh-mocks@0.0.10","_shasum":"1adb60935d7a0b33ddbe8a55611b8481e60ba5bd","_from":".","_npmVersion":"2.7.5","_nodeVersion":"0.10.24","_npmUser":{"name":"evanshortiss","email":"evanshortiss@gmail.com"},"maintainers":[{"name":"evanshortiss","email":"evanshortiss@gmail.com"}],"dist":{"shasum":"1adb60935d7a0b33ddbe8a55611b8481e60ba5bd","tarball":"https://registry.npmjs.org/fh-mocks/-/fh-mocks-0.0.10.tgz","integrity":"sha512-mU+xGV7KlcJ5nFv84ug5Z5j0wRzNS3DQpJi+tMikb+U1cchrW1Qy/qaZ9LDr4i32Z5+PtXQIKa7LFte5apz3hQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAiuVUZ0PZDuNLUY/G/FfStb2Z3G5zOayYrqcAHSrKe7AiEA1v6TppHmJ5FDanXRzkr2AeRRqvDXKdKxsxXzWCYSVUA="}]}},"0.0.11":{"name":"fh-mocks","version":"0.0.11","description":"Mocks for the fh-js-sdk to enable unit testing of application logic.","main":"./lib/api.js","scripts":{"test":"make test"},"keywords":["fh","fh-js-sdk","fh-mocks","mocks","feedhenry","unit","testing"],"author":{"name":"Evan Shortiss"},"license":"MIT","devDependencies":{"linelint":"0.0.3","lintspaces-cli":"0.0.4","mocha":"~1.21.4","jshint":"~2.5.3","chai":"~1.9.1","sinon":"~1.10.3","browserify":"~5.10.0"},"dependencies":{"xtend":"~4.0.0"},"gitHead":"b0fa03080eb7497636bd0e9514d2addb73b55165","_id":"fh-mocks@0.0.11","_shasum":"a387c6e894f441df4435acd8eeccba31a9b33e28","_from":".","_npmVersion":"2.7.5","_nodeVersion":"0.10.24","_npmUser":{"name":"evanshortiss","email":"evanshortiss@gmail.com"},"maintainers":[{"name":"evanshortiss","email":"evanshortiss@gmail.com"}],"dist":{"shasum":"a387c6e894f441df4435acd8eeccba31a9b33e28","tarball":"https://registry.npmjs.org/fh-mocks/-/fh-mocks-0.0.11.tgz","integrity":"sha512-KvwPE0MroFXpCAD/opoJapN65GOOOzmIJUMQT88E584wJ9z3AjVi7ZKnArrpob2ccWNUjRIATFc0j+664uT7ZA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAUQLtJbIjyut97wKk9gLx1p5SuUX60Rjw3BFhhAjtXSAiEAhq60zRb4TkzmUE+oZYAApofeWBwk0qkVMbU9hvVVM+8="}]}},"0.1.0":{"name":"fh-mocks","version":"0.1.0","description":"Mocks for the fh-js-sdk to enable unit testing of application logic.","main":"./lib/api.js","scripts":{"test":"make test"},"keywords":["fh","fh-js-sdk","fh-mocks","mocks","feedhenry","unit","testing"],"author":{"name":"Evan Shortiss"},"license":"MIT","devDependencies":{"linelint":"0.0.3","lintspaces-cli":"0.0.4","mocha":"~1.21.4","jshint":"~2.5.3","chai":"~1.9.1","sinon":"~1.10.3","browserify":"~5.10.0"},"dependencies":{"deep-eql":"^0.1.3","xtend":"~4.0.0"},"gitHead":"52153283d3ab474ff5d1cc00e973d72d90eaa989","_id":"fh-mocks@0.1.0","_shasum":"72e3a2b591cb4c68df25683fa27ba7c7aa3952fb","_from":".","_npmVersion":"2.7.5","_nodeVersion":"0.10.24","_npmUser":{"name":"evanshortiss","email":"evanshortiss@gmail.com"},"maintainers":[{"name":"evanshortiss","email":"evanshortiss@gmail.com"}],"dist":{"shasum":"72e3a2b591cb4c68df25683fa27ba7c7aa3952fb","tarball":"https://registry.npmjs.org/fh-mocks/-/fh-mocks-0.1.0.tgz","integrity":"sha512-P4Gaa7Ucq3QIGz3/jqkDnYkyJ56okK2IayL6bD6Y6Nb5VHJqlyLPGT6+ZsW2J1RXwzvzot+h01mvARY19q84eg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHQc/lc+fh7tNwX3Jn4XZgUfNvsL0u4/3cr/4ckIhXGcAiBLVbAaWFhUoNHnasOdd/TpQE3/5I2pvjd750qK8q+zgw=="}]}},"0.1.1":{"name":"fh-mocks","version":"0.1.1","description":"Mocks for the fh-js-sdk to enable unit testing of application logic.","main":"./lib/api.js","repository":{"type":"git","url":"https://github.com/feedhenry-staff/fh-js-mocks"},"scripts":{"test":"make test"},"keywords":["fh","fh-js-sdk","fh-mocks","mocks","feedhenry","unit","testing"],"author":{"name":"Evan Shortiss"},"license":"MIT","devDependencies":{"linelint":"0.0.3","lintspaces-cli":"0.0.4","mocha":"~1.21.4","jshint":"~2.5.3","chai":"~1.9.1","sinon":"~1.10.3","browserify":"~5.10.0"},"dependencies":{"deep-eql":"^0.1.3","xtend":"~4.0.0"},"gitHead":"b318cfabca3cd3d12e821dba8365f27d38e3406b","bugs":{"url":"https://github.com/feedhenry-staff/fh-js-mocks/issues"},"homepage":"https://github.com/feedhenry-staff/fh-js-mocks","_id":"fh-mocks@0.1.1","_shasum":"95c8f0cdc4f700cd30d31a7a59e207d199f72bad","_from":".","_npmVersion":"2.7.5","_nodeVersion":"0.10.24","_npmUser":{"name":"evanshortiss","email":"evanshortiss@gmail.com"},"maintainers":[{"name":"evanshortiss","email":"evanshortiss@gmail.com"}],"dist":{"shasum":"95c8f0cdc4f700cd30d31a7a59e207d199f72bad","tarball":"https://registry.npmjs.org/fh-mocks/-/fh-mocks-0.1.1.tgz","integrity":"sha512-e4ykqceopByHP4YPp+o+yZCx60bD8lUbzlA9+iYQBAuxWzYH9K1+OFry2pUSbXXUahZyhReQO++FDh1fmv8cbg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF/QzhThHeM2SJeOKFmmaWvIFtLY3vjNZFAeYB7FOR4WAiAVn73c7DBq7nbGhadgP+eOY9r7N3kiIJ5RO0/CLW8Qww=="}]}}},"readme":"FeedHenry Mocks\n===============\n\n[![build-status](https://travis-ci.org/feedhenry-staff/fh-js-mocks.svg?branch=master)\n](https://travis-ci.org/feedhenry-staff/fh-js-mocks.svg?branch=master)[![version](https://badge.fury.io/js/fh-mocks.svg)\n](https://badge.fury.io/js/fh-mocks.svg)\n\nA library that enables you to mock out APIs from the FeedHenry JS SDK. This \nenables unit testing of application logic without the need to actually run the \nSDK code which may be impractical or impossible for testing purposes.\n\n## Usage\nTo use this mocking library simply include it in a script tag in a custom test \nHTML file or inject it using Karma (which is a much better idea). Alternatively\nyou can run your tests in a Node.js environment since this module will create a\n_$fh_ global on either _window_ or _global_ depending on where you're running \nit, a browser or Node.js respectively. See \n[here](https://github.com/feedhenry-staff/cloud-connection-monitor) for an \nexample of Node.js tests for a library that is actually meant for a browser!\n\nThis should be included *instead of* or *after* the standard _feedhenry.js_ SDK \nscript when testing.\n\nWhat's nice about this is that you can write all tests in a blocking \nmanner which keeps things pretty simple. You can write them using non-blocking \nsyntax via the usual Jasmine/Mocha *done* callback (these are the only two I'm \nfamiliar with) if required too, just call the mock *flush* method when \nappropriate.\n\n\n## Example\n```javascript\n\n'use strict';\n\nvar assert = require('assert');\n// var fh = require('fh-js-mocks') <-- Possible with browserify\n\nvar USER = 'johndoe',\n\tPASS = 'ismaithliomcácamilis';\n\ndescribe('Some Controller/Model', function () {\n\t\n\tafterEach(function () {\n\t\t// Makes sure we're using and responding to all request planned per test\n\t\t// If you define an expect and never send the corresponding \n\t\t// request ($fh.act) then verifyNoOutstandingExpectation will throw an\n\t\t// error. The same goes for verifyNoOutstandingRequest expect it throws\n\t\t// for requests that have no expectation to match\n\t\t$fh.act.verifyNoOutstandingRequest();\n\t\t$fh.act.verifyNoOutstandingExpectation();\n\n\t\t// This is optional. It will restore the original act function\n\t\t// if you have included feedhenry.js\n\t\t$fh.restoreOriginalApi('act');\n\t});\n\n\tbeforeEach(function () {\n\t\t// Create a shim function to replace the regular before running tests\n\t\t$fh.createApiShim('act');\n\t});\n\n\n\tdescribe('#login', function () {\n\n\t\tit('Should successfully login.', function () {\n\t\t\t// We tell $fh.act that a request with these parameters should be\n\t\t\t// expected to be called.\n\t\t\t$fh.act.expect({\n\t\t\t\tact: 'login',\n\t\t\t\treq: {\n\t\t\t\t\tu: USER,\n\t\t\t\t\tp: PASS\n\t\t\t\t}\n\t\t\t})\n\t\t\t// The set response function takes two args. \n\t\t\t// The first arg, if not null will cause the error/fail callback\n\t\t\t// to be called with the given value. The second arg will be the \n\t\t\t// result passed to the success callback but will only be triggered \n\t\t\t// if the first arg is null\n\t\t\t.setResponse(null, {\n\t\t\t\tsession: 'e4b6f7cfbe45a24e4773c6c2f59a0c41'\n\t\t\t\tdata: {\n\t\t\t\t\tuser: USER,\n\t\t\t\t\tdob: '1985-08-13'\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// The login function uses $fh.act internally\n\t\t\tMyController.login(USER, PASS, function (err, res) {\n\t\t\t\tassert.equal(err, null);\n\t\t\t\tassert(res);\n\t\t\t\tassert.equal(typeof res.session, 'string');\n\t\t\t\t// etc...\n\t\t\t});\n\n\t\t\t// Respond to any requests we've queued to $fh.act so far.\n\t\t\t// This will trigger the callback provided to MyController.login\n\t\t\t$fh.act.flush();\n\t\t});\n\n\t});\n\n});\n```\n\n\n## API\nThis library mimics the normal FeedHenry JavaScript SDK. As you might be aware \nthe majority of API functions work like so: \n\n```javascript\n$fh.someApi(options, successCallback, failCallback);\n```\n\nThis library allows you to override existing implementations, and will create \none if none exists. For example this will replace/create the $fh.act API:\n\n```\n$fh.createShim('act');\n```\n\n### MockApiInstance\nCreated using _$fh.createApiShim(name)_. Works just like a regular $fh API. \nWell, *almost* like a regular API. It's still a same old function definition \nyou know and love: _$fh.someApi(opts, success, fail)_. What's different is that \nit has some new functions appended as described here, and demonstrated in the \nexamples.\n\n##### MockApiInstance.expect(input)\nThe expect function tells our mock API service to expect a specific _input_ and \nreturns a *MockApiResponder* that allows us to configure a response scenario \nfor the given _input_ as detailed below.\n\n##### MockApiInstance.flush([count])\nRespond to *count* calls that have been queued to the API mock. Calls are only \nresponed to if the same parameters it provided were given via an expect. The \nparameter comparison is done by using _JSON.stringify_ on your inputs passed to \n_$fh.shim.expect(input)_ and _$fh.shim(inputs, success, fail)_.\n\nYou'll probably not need to supply the optional _count_ argument often, perhaps \neven never.\n\n##### MockApiInstance.verifyNoOutstandingRequest()\nVerify that all calls to your shim were satisfied. Can be called in an \n*afterEach* hook to ensure you're cleanly responding to each call.\n\n##### MockApiInstance.verifyNoOutstandingExpectation()\nVerify that all expectations had a request made for them. Can be called in an \n*afterEach* hook to ensure you're not defining unnecessary expectations and \nthat those you do declare are utilised.\n\n### MockApiResponder\nAn instance of this is returned from $fh.shim.expect. This class should be \nused to configure responses to your SDK inputs. The only function you should \nneed to use is *setResponse* unless certain edge cases arise that require \notherwise.\n\n##### setResponse(err, res)\nConfigure the response that should be returned when inputs to _expect_ match \nthe input you provide to $fh.shim. Providing a non *null* value as the first \nparameter will cause the error callback you provided to the SDK to be called \nupon flushing the api call queue using _flush_. See the example below:\n\n```javascript\n\ndescribe('Test Our Push Module', function () {\n\tafterEach(function () {\n\t\t$fh.push.verifyNoOutstandingRequest();\n\t\t$fh.push.verifyNoOutstandingExpectation();\n\t\t$fh.restoreOriginalApi('push');\n\t});\n\n\tbeforeEach(function () {\n\t\t// Create a shim function for $fh.push\n\t\t$fh.createApiShim('push');\n\t});\n\n\tit('Should handle failure and return SDK error', function () {\n\t\tvar ERR_CODE = 'push_nosupport';\n\n\t\tvar responder = $fh.push.expect({\n\t\t\tact: 'register'\n\t\t});\n\n\t\tresponder.setResponse(ERR_CODE, null);\n\n\t\t// Uses $fh.push internally\n\t\tPushModule.register(funcion (sdkError, result) {\n\t\t\tassert.equal(sdkError, ERR_CODE);\n\t\t});\n\n\t\t$fh.push.flush();\n\t});\n\n\tit('Should handle failure and return SDK error', function () {\n\t\tvar FAKE_TEST_RES = {\n\t\t\tdeviceToken: '12345890'\n\t\t};\n\n\t\tvar responder = $fh.push.expect({\n\t\t\tact: 'register'\n\t\t});\n\n\t\tresponder.setResponse(null, FAKE_TEST_RES);\n\n\t\t// Uses $fh.push internally\n\t\tPushModule.register(funcion (sdkError, result) {\n\t\t\tassert(result)\n\t\t\tassert.equal(result.deviceToken, FAKE_TEST_RES.deviceToken);\n\t\t});\n\n\t\t$fh.push.flush();\n\t});\n});\n\n```\n\n\n\n\n\n\n","maintainers":[{"name":"evanshortiss","email":"evanshortiss@gmail.com"}],"time":{"modified":"2022-06-18T00:25:19.794Z","created":"2014-09-09T13:28:58.661Z","0.0.0":"2014-09-09T13:28:58.661Z","0.0.1":"2014-09-09T13:32:20.017Z","0.0.2":"2014-09-12T13:25:39.525Z","0.0.3":"2014-09-12T13:26:58.131Z","0.0.4":"2015-01-22T02:04:19.355Z","0.0.5":"2015-01-22T14:03:48.310Z","0.0.6":"2015-05-29T17:50:55.495Z","0.0.7":"2015-05-29T18:10:00.718Z","0.0.9":"2015-05-29T18:21:40.379Z","0.0.10":"2015-05-30T21:05:36.937Z","0.0.11":"2015-06-12T20:02:28.949Z","0.1.0":"2015-07-10T13:05:02.819Z","0.1.1":"2015-07-10T13:28:55.050Z"},"keywords":["fh","fh-js-sdk","fh-mocks","mocks","feedhenry","unit","testing"],"author":{"name":"Evan Shortiss"},"license":"MIT","readmeFilename":"README.md","users":{},"homepage":"https://github.com/feedhenry-staff/fh-js-mocks","repository":{"type":"git","url":"https://github.com/feedhenry-staff/fh-js-mocks"},"bugs":{"url":"https://github.com/feedhenry-staff/fh-js-mocks/issues"}}