-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-24198] Force include Foundation framework (2.0.X) #115
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ var should = require('should'), | |
generator = require('../lib/generate/index'), | ||
util = require('../lib/generate/util'), | ||
nodePath = require('path'), | ||
wrench = require('wrench'), | ||
buildDir = nodePath.join(__dirname, '..', 'build', 'hyperloop'); | ||
|
||
function Hyperloop () { | ||
|
@@ -71,13 +72,14 @@ describe('generate', function () { | |
beforeEach(function () { | ||
global.Hyperloop = Hyperloop; | ||
global.HyperloopObject = HyperloopObject; | ||
|
||
if (fs.existsSync(buildDir)) { | ||
wrench.rmdirSyncRecursive(buildDir); | ||
} | ||
wrench.mkdirSyncRecursive(buildDir); | ||
}); | ||
|
||
before(function () { | ||
|
||
!fs.existsSync(nodePath.dirname(buildDir)) && fs.mkdir(nodePath.dirname(buildDir)); | ||
!fs.existsSync(buildDir) && fs.mkdir(buildDir); | ||
|
||
var proxyCount = 0; | ||
var Module = require('module').Module; | ||
var old_nodeModulePaths = Module._nodeModulePaths; | ||
|
@@ -158,6 +160,14 @@ describe('generate', function () { | |
|
||
// setup the node path to resolve files that we generated | ||
addPath(nodePath.dirname(buildDir)); | ||
|
||
var originalRequire = Module.prototype.require; | ||
Module.prototype.require = function(path) { | ||
if (/^\/hyperloop/.test(path)) { | ||
path = path.slice(1); | ||
} | ||
return originalRequire.call(this, path); | ||
}; | ||
}); | ||
|
||
it('should generate UIView', function (done) { | ||
|
@@ -243,4 +253,36 @@ describe('generate', function () { | |
}); | ||
}); | ||
}); | ||
|
||
it('should always generate Foundation', function (done) { | ||
var includes = [ | ||
'<Intents/INPreferences.h>' | ||
]; | ||
generateMetabase(includes, function (err, json, outfile) { | ||
should(err).not.be.ok; | ||
should(json).be.ok; | ||
var state = generator.generateState(); | ||
generator.generate('Foundation', buildDir, outfile, state, function (err) { | ||
should(err).not.be.ok; | ||
// Check some Foundation basics... | ||
var Foundation = require(nodePath.join(buildDir, 'foundation/foundation.js')); | ||
should(Foundation).be.a.function; | ||
should(Foundation.NSUTF8StringEncoding).be.a.number; | ||
var NSString = require(nodePath.join(buildDir, 'foundation/nsstring.js')); | ||
should(NSString).be.a.function; | ||
should(NSString.name).be.equal('NSString'); | ||
var instance = new NSString(); | ||
should(instance).be.an.object; | ||
should(instance.className).be.equal('NSString'); | ||
should(instance.$native).be.an.object; | ||
|
||
// ... and if INPreferences is genreated correctly, which does not work without | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo in |
||
// explicitly including Foundation framework | ||
var INPreferences = require(nodePath.join(buildDir, 'intents/inpreferences.js')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we only run the test with iOS 10+? Otherwise, we need to wrap this out for iOS 9. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests are currently not run by the CI build at all and need to be triggered manually, so you have to make sure to run them with Xcode 8 / iOS 10 selected. Most of them are broken anyway and i'll rework them in a separate PR. |
||
should(INPreferences).be.a.function; | ||
should(INPreferences.siriAuthorizationStatus).be.a.function; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex matches for some incorrect require-statements. Replace at least the latter
<
with>
.