-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Preserving [global] as [this] when executing a yui module in nodejs. #1360
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ab984c4
Preserving [global] as [this] when executing a yui module in nodejs.
caridy 3d80c47
review feedback: removing unnecessary [] argument when calling apply()
caridy abb2306
adding unit test for Y.get vendor script use-case
caridy 7534825
review feedback: newline
caridy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// script trying to store a global variable called `foo` | ||
(function (global) { | ||
global.foo = 1; | ||
}(this)); | ||
|
||
// signing the vendor script with a YUI module name | ||
// and optionally, adding the value of `foo` to the namespace | ||
YUI.add('vendor-script-signed', function (Y) { | ||
Y.foo = Y.config.global.foo; | ||
}, '', {}); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env node | ||
|
||
process.chdir(__dirname); | ||
|
||
var YUITest = require('yuitest'), | ||
path = require('path'), | ||
fs = require('fs'), | ||
dir = path.join(__dirname, '../../../../build-npm/'), | ||
YUI = require(dir).YUI, | ||
json; | ||
|
||
YUI({ useSync: true }).use('test', function(Y) { | ||
Y.Test.Runner = YUITest.TestRunner; | ||
Y.Test.Case = YUITest.TestCase; | ||
Y.Test.Suite = YUITest.TestSuite; | ||
Y.Assert = YUITest.Assert; | ||
|
||
Y.applyConfig({ | ||
modules: { | ||
'get-vendor-test': { | ||
fullpath: path.join(__dirname, '../unit/assets/vendor-test.js'), | ||
requires: ['get', 'vendor-script-signed', 'test'] | ||
}, | ||
'vendor-script-signed': { | ||
fullpath: path.join(__dirname, '../assets/vendor-signed.js') | ||
} | ||
} | ||
}); | ||
|
||
Y.use('get-vendor-test'); | ||
|
||
Y.Test.Runner.setName('get cli tests'); | ||
Y.Test.Runner.add(Y.GetTests.vendor); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
YUI.add('get-vendor-test', function (Y) { | ||
|
||
Y.GetTests = new Y.Test.Suite("get vendor"); | ||
|
||
Y.GetTests.vendor = new Y.Test.Case({ | ||
name: "Y.get vendor tests", | ||
|
||
'test: global to work across runtimes' : function() { | ||
Y.Assert.areEqual(1, Y.foo, 'Y.config.global.foo is not set correctly'); | ||
} | ||
}); | ||
|
||
}, '', { | ||
requires: ['get', 'vendor-script-signed', 'test'] | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
<html> | ||
<head> | ||
<title>YUI Get Vendor Tests</title> | ||
</head> | ||
<body class="yui3-skin-sam"> | ||
|
||
<div id="log"></div> | ||
|
||
<script src="../../../../build/yui/yui.js"></script> | ||
<script src="../assets/vendor-signed.js" charset="utf-8"></script> | ||
<script src="./assets/vendor-test.js" charset="utf-8"></script> | ||
|
||
<script> | ||
var YUI_config = { | ||
gconfig: true, | ||
gfilter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'raw' | ||
}; | ||
|
||
var Y = YUI({ | ||
allowRollup: false, | ||
filter: YUI_config.gfilter | ||
}).use('get-vendor-test', 'test-console', function(Y) { | ||
new Y.Test.Console().render('#log'); | ||
Y.Test.Runner.add(Y.GetTests.vendor); | ||
Y.Test.Runner.run(); | ||
}); | ||
</script> | ||
|
||
</body> | ||
</html> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Newline.