Last active
December 18, 2015 18:29
-
-
Save toddself/5825886 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* barnstormer | |
* https://github.com/condenast/barnstormer | |
* | |
* Copyright (c) 2013 Condé Nast. All rights reserved. | |
*/ | |
var sync; | |
if (typeof define !== 'function') { | |
var define = require('amdefine')(module); | |
sync = require('../../lib/mongo_sync'); | |
} | |
define(function (require) { | |
'use strict'; | |
var Backbone = require('backbone'); | |
if(typeof sync !== 'undefined'){ | |
Backbone.sync = sync; | |
} | |
var NewsletterStory = Backbone.Model.extend({ | |
url: '/parse', | |
idAttribute: '_id', | |
defaults: { | |
hed: '', | |
dek: '', | |
trunc_hed: '', | |
img: '', | |
url: '', | |
section: '', | |
expand: false, | |
name: '' | |
} | |
}); | |
return NewsletterStory; | |
}); |
This file contains 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
/* global requirejs */ | |
requirejs.config({ | |
baseUrl: '../', | |
hbs: { | |
disableI18n: true, | |
helperPathCallback: function (name) { | |
'use strict'; | |
return 'views/helpers/' + name; | |
} | |
}, | |
paths: { | |
'jquery': 'components/jquery/jquery', | |
'underscore': 'components/underscore/underscore', | |
'backbone': 'components/backbone/backbone', | |
'handlebars': 'components/handlebars/handlebars', | |
'hbs': 'components/require-handlebars-plugin/hbs', | |
'i18nprecompile': 'components/require-handlebars-plugin/hbs/i18nprecompile', | |
'json2': 'components/require-handlebars-plugin/hbs/json2', | |
'moment': 'components/moment/moment', | |
'bootstrap': 'components/bootstrap/js/bootstrap' | |
}, | |
shim: { | |
'backbone': { | |
deps: ['underscore', 'jquery'], | |
exports: 'Backbone' | |
}, | |
'handlebars': { | |
exports: 'Handlebars' | |
}, | |
'underscore': { | |
exports: '_' | |
}, | |
'bootstrap': { | |
deps: ['jquery'], | |
exports: 'jQuery.fn.modal' | |
} | |
} | |
}); | |
requirejs.config({ | |
baseUrl: window.PHANTOMJS ? '../' : '/../', | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So
grunt mocha
provides awindow
object, so if you block code from running on the front end withtypeof window === 'undefined'
that doesn't work in your test suite. For some reason wrapping your code in:Would cause a script error with require when trying to import it. (Seriously.)
This is the only pattern I've gotten working yet to make code run only in a particular environment and still have the test suite work...