raphinesse commented on a change in pull request #1212:
URL: https://github.com/apache/cordova-android/pull/1212#discussion_r658042594
##########
File path: spec/unit/prepare.spec.js
##########
@@ -783,6 +783,20 @@ describe('prepare', () => {
Api = rewire('../../bin/templates/cordova/Api');
prepare = rewire('../../bin/templates/cordova/lib/prepare');
+ prepare.__set__('require.resolve', (file) => {
+ if (file === 'cordova-android/framework/defaults.json') {
+ return path.resolve('./framework/defaults.json');
+ }
+ return path.resolve(file);
+ });
+
+ const defaults = require('../../framework/defaults.json');
+
+ prepare.__set__('fs', {
+ readJSONSync: () => defaults,
Review comment:
All reads will return the defaults. Is this desired? Moreover, the same
object instance will be returned to all tests, making them prone to influence
each other.
##########
File path: spec/unit/prepare.spec.js
##########
@@ -783,6 +783,20 @@ describe('prepare', () => {
Api = rewire('../../bin/templates/cordova/Api');
prepare = rewire('../../bin/templates/cordova/lib/prepare');
+ prepare.__set__('require.resolve', (file) => {
+ if (file === 'cordova-android/framework/defaults.json') {
+ return path.resolve('./framework/defaults.json');
+ }
+ return path.resolve(file);
+ });
Review comment:
There's more than one thing wrong with this mock. Would be great if we
would not have to do this at all. But for now that would mean that we have to
copy the defaults to the project as well. Then again, do we really need to
revert to the defaults each time we prepare?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]