mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 15:56:10 +08:00
[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:
parent
82e7a276a3
commit
097a96274f
|
@ -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",
|
||||
|
|
|
@ -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)
|
||||
|
|
19
packages/isomorphic-core/spec/jasmine/polyfills.es6
Normal file
19
packages/isomorphic-core/spec/jasmine/polyfills.es6
Normal 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;
|
||||
}
|
||||
}
|
2
packages/isomorphic-core/spec/run.es6
Normal file
2
packages/isomorphic-core/spec/run.es6
Normal file
|
@ -0,0 +1,2 @@
|
|||
import executeJasmine from './jasmine/execute'
|
||||
executeJasmine()
|
Loading…
Reference in a new issue