Skip to content
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"mongodb-runner": "^3.4.0",
"react-addons-test-utils": "^15.2.1",
"sinon": "^1.17.6",
"sinon-chai": "^2.8.0",
"spectron": "^3.2.6",
"xvfb-maybe": "^0.1.3"
},
Expand Down
4 changes: 2 additions & 2 deletions src/app/connect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var dialog = remote.dialog;
var Clipboard = remote.clipboard;
var BrowserWindow = remote.BrowserWindow;
var metrics = require('mongodb-js-metrics')();
var COMPASS_ICON = require('../../icon');
var COMPASS_ICON_PATH = require('../../icon').path;

var debug = require('debug')('mongodb-compass:connect:index');

Expand Down Expand Up @@ -332,7 +332,7 @@ var ConnectView = View.extend({
// ask user if Compass should use it to fill out form
dialog.showMessageBox(BrowserWindow.getFocusedWindow(), {
type: 'info',
icon: COMPASS_ICON,
icon: COMPASS_ICON_PATH,
message: 'MongoDB connection string detected',
detail: 'Compass detected a MongoDB connection string in your '
+ 'clipboard. Do you want to use the connection string to '
Expand Down
4 changes: 2 additions & 2 deletions src/internal-packages/schema/lib/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const schemaStream = require('mongodb-schema').stream;
const toNS = require('mongodb-ns');
const ReadPreference = require('mongodb').ReadPreference;

const COMPASS_ICON = require('../../../../icon');
const COMPASS_ICON_PATH = require('../../../../icon').path;

/**
* The default read preference.
Expand Down Expand Up @@ -78,7 +78,7 @@ const SchemaStore = Reflux.createStore({

dialog.showMessageBox(BrowserWindow.getFocusedWindow(), {
type: 'info',
icon: COMPASS_ICON,
icon: COMPASS_ICON_PATH,
message: 'Share Schema',
detail: detail,
buttons: ['OK']
Expand Down
52 changes: 52 additions & 0 deletions test/renderer/share-schema-as-json.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* eslint no-unused-expressions: 0 */
const app = require('hadron-app');
const sinon = require('sinon');
const { remote } = require('electron');
const chai = require('chai');
const sinonChai = require('sinon-chai');
const expect = chai.expect;
const COMPASS_ICON_PATH = require('../../src/icon').path;

// For `expect(mySpy).to.have.been.calledWith("foo");` syntax
chai.use(sinonChai);

describe('SchemaStore', function() {
let writeText;
let showMessageBox;

beforeEach(function() {
this.SchemaStore = app.appRegistry.getStore('Schema.Store');
this.clipboardSpy = sinon.spy();
this.messageBoxSpy = sinon.spy();
writeText = remote.clipboard.writeText;
showMessageBox = remote.dialog.showMessageBox;
remote.clipboard.writeText = this.clipboardSpy;
remote.dialog.showMessageBox = this.messageBoxSpy;
});

afterEach(function() {
remote.clipboard.writeText = writeText;
remote.dialog.showMessageBox = showMessageBox;
});

context('shares a "null" schema as JSON', function() {
beforeEach(function() {
// Note that normally this menu option is only exposed after the user has
// connected to an instance, navigated to a collection and sampled schema
this.SchemaStore.handleSchemaShare();
});
it('copies to the clipboard', function() {
expect(this.clipboardSpy).to.have.been.calledWith('null');
});
it('displays an informative message box', function() {
expect(this.messageBoxSpy).to.have.been.calledWith(null, {
buttons: ['OK'],
detail: 'The schema definition of ' +
' has been copied to your clipboard in JSON format.',
icon: COMPASS_ICON_PATH,
message: 'Share Schema',
type: 'info'
});
});
});
});