Skip to content
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

Do not clobber console.log to spy on it #782

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions spec/unit/android_sdk.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@ describe('android_sdk', () => {
describe('print_newest_available_sdk_target', () => {
it('should log the newest version', () => {
const sortedIds = ['android-27', 'android-24', 'android-23', 'android-19'];
const logSpy = jasmine.createSpy('log');

spyOn(android_sdk, 'list_targets').and.returnValue(Promise.resolve(sortedIds));
spyOn(sortedIds, 'sort');

android_sdk.__set__({ console: { log: logSpy } });
spyOn(console, 'log');

return android_sdk.print_newest_available_sdk_target().then(() => {
expect(sortedIds.sort).toHaveBeenCalledWith(android_sdk.__get__('sort_by_largest_numerical_suffix'));
expect(logSpy).toHaveBeenCalledWith(sortedIds[0]);
expect(console.log).toHaveBeenCalledWith(sortedIds[0]);
});
});
});
Expand Down
6 changes: 2 additions & 4 deletions spec/unit/run.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ describe('run', () => {

describe('help', () => {
it('should print out usage and help', () => {
const logSpy = jasmine.createSpy();
const errorSpy = jasmine.createSpy();
run.__set__({ console: { log: logSpy, error: errorSpy } });
spyOn(console, 'log');

// Rewiring the process object in entirety does not work on NodeJS 12.
// Rewiring members of process however does work
Expand All @@ -213,7 +211,7 @@ describe('run', () => {
run.__set__('process.argv', ['', '']);

run.help();
expect(logSpy).toHaveBeenCalledWith(jasmine.stringMatching(/^Usage:/));
expect(console.log).toHaveBeenCalledWith(jasmine.stringMatching(/^Usage:/));
});
});
});