[isomorphic-core] Make sure specs can run without electron

Summary:
Isomorphic-core should be functional outside of the client environment

Depends on D4056

Test Plan: Run the test suite

Reviewers: evan, spang, juan

Reviewed By: spang, juan

Differential Revision: https://phab.nylas.com/D4062
This commit is contained in:
Halla Moore 2017-02-28 15:49:30 -08:00
parent 82e7a276a3
commit 097a96274f
4 changed files with 31 additions and 0 deletions

View file

@ -3,6 +3,13 @@
"version": "0.0.1",
"description": "Packages use isomorphically on n1-cloud and client-sync",
"main": "index.js",
"scripts": {
"test": "babel-node spec/run.es6"
},
"devDependencies": {
"babel-cli": "6.x.x",
"jasmine": "2.x.x"
},
"dependencies": {
"atob": "2.0.3",
"imap": "github:jstejada/node-imap#fix-parse-body-list",

View file

@ -1,5 +1,8 @@
import applyPolyfills from './polyfills'
export default class JasmineExtensions {
extend({beforeEach, afterEach} = {}) {
applyPolyfills()
global.it = this._makeItAsync(global.it)
global.fit = this._makeItAsync(global.fit)
global.beforeAll = this._makeEachOrAllFnAsync(global.beforeAll)

View file

@ -0,0 +1,19 @@
// We use Jasmine 1 in the client tests and Jasmine 2 in the cloud tests,
// but isomorphic-core tests need to be run in both environments. Tests in
// isomorphic-core should use Jasmine 1 syntax, and then we can add polyfills
// here to make sure that they exist when we run in a Jasmine 2 environment.
export default function applyPolyfills() {
const origSpyOn = global.spyOn;
// There's no prototype to modify, so we have to modify the return
// values of spyOn as they're created.
global.spyOn = (object, methodName) => {
const originalValue = object[methodName]
const spy = origSpyOn(object, methodName)
object[methodName].originalValue = originalValue;
spy.andReturn = spy.and.returnValue;
spy.andCallFake = spy.and.callFake;
Object.defineProperty(spy.calls, 'length', {get: function getLength() { return this.count(); }})
return spy;
}
}

View file

@ -0,0 +1,2 @@
import executeJasmine from './jasmine/execute'
executeJasmine()