From 97f50c5bf58f683be6f46c80c976d780e5e7fc56 Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Thu, 5 Jan 2012 01:36:53 +0000 Subject: [PATCH] [test/model][s]: update webstore backend test to have ajax fully mocked so tests work fully when offline. --- test/model.test.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/model.test.js b/test/model.test.js index b27fabf9..f2b628b7 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -119,7 +119,6 @@ webstoreData = { }; test('Webstore Backend', function() { - stop(); var backend = new recline.Model.BackendWebstore({ url: 'http://webstore.test.ckan.org/rufuspollock/demo/data' }); @@ -127,9 +126,18 @@ test('Webstore Backend', function() { dataset = backend.getDataset(); var stub = sinon.stub($, 'ajax', function(options) { - return { - then: function(callback) { - callback(webstoreSchema); + if (options.url.indexOf('schema.json') != -1) { + return { + then: function(callback) { + callback(webstoreSchema); + } + } + } else { + console.log('here'); + return { + then: function(callback) { + callback(webstoreData); + } } } }); @@ -137,10 +145,7 @@ test('Webstore Backend', function() { dataset.fetch().then(function(dataset) { deepEqual(['__id__', 'date', 'geometry', 'amount'], dataset.get('headers')); equal(3, dataset.rowCount) - // restore mocked method - $.ajax.restore(); dataset.getRows().then(function(docList) { - start(); equal(3, docList.length) equal("2009-01-01", docList.models[0].get('date')); });