Last active
October 14, 2015 12:14
-
-
Save fritzvd/0b4f4f3dddcece990580 to your computer and use it in GitHub Desktop.
Mocking / Stubbing tns-core-modules for NativeScript testing on your host device
This file contains hidden or 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
var assert = require('assert'); | |
var proxyquire = require('proxyquire'); | |
var fetchStub = require('node-fetch'); // the npm package not the tns-core-module (npm install --save-dev node-fetch) | |
var obsArray = Array; | |
var YourViewModel = proxyquire('../app/view-models/your-view-model', | |
{ | |
fetch: fetchStub, | |
"data/observable-array": { | |
ObservableArray: Array, | |
'@noCallThru': true | |
} | |
}); | |
describe('YourViewModel', function () { | |
describe('load', function () { | |
it('should load the shit', function () { | |
var yvm = YourViewModel(); | |
yvm.push({title: 'this item'}) | |
assert(yvm.length, 1); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment