ipcMain.on('application:download', function(event, buffer) { let filename = dialog.showSaveDialog(BrowserWindow.getFocusedWindow(), { title: 'Download to File…', filters: [ { name: 'All Files', extensions: ['*'] } ] }); if(filename) { fs.writeFile(filename, buffer, (err) => { let options = { buttons: ['Close'] }; if(err) { options = _.extend(options, { title: 'Download Error', type: 'error', message: err.name || 'Export Error', detail: err.toString() }); } else { options = _.extend(options, { title: 'Download Success', type: 'info', message: `Saved to ${filename}` }); } dialog.showMessageBox(BrowserWindow.getFocusedWindow(), options); }); } });
async(function*(options) { options = _.extend({ directory: path.resolve(path.join(__dirname, "./prototype")), std: "c++98" }, options); let buildSystem = new BuildSystem(options); if (!/visual studio/i.test(buildSystem.toolset.generator)) { let command = yield buildSystem.getConfigureCommand(); assert.equal(command.indexOf("-std=c++11"), -1, "c++11 still forced"); } })
author () { this.answers = _.extend(this.answers, { author: this.user.git.name() + ' <' + this.user.git.email() + '>' }) }
QUnit.test('listenTo yourself cleans yourself up with stopListening', function(assert) { assert.expect(1); var e = _.extend({}, Backbone.Events); e.listenTo(e, 'foo', function(){ assert.ok(true); }); e.trigger('foo'); e.stopListening(); e.trigger('foo'); });
ep.all('user_saved', 'catetory_saved', function (user, catetory) { // 拼接两个返回的数据,确保返回的是一个完整的数据 article = _.extend(user, catetory) console.log('-----------------') console.log(article) console.log('-----------------') // 设置缓存数据 cache.set('article_' + article.id, article, tools.time.M(true)) return resJSON(res, true, 10000, '发布成功', { article }) })
getDetailOfId(id) .then((detail) => response.json(_.extend({}, detail, { id: id }))) .catch((error) => response.json({ status: error.status, message: 'cannot access to the mongodb', }))
_genBaseRequest(data) { return _.extend({ BaseRequest: { Uin: this.loginData.uin, Sid: this.loginData.sid, SKey: this.loginData.skey, DeviceID: WechatClient.getDeviceID(), }, }, data); }
QUnit.test('#1206 - Strip leading slash before location.assign.', function(assert) { assert.expect(1); Backbone.history.stop(); location.replace('http://example.com/root/'); Backbone.history = _.extend(new Backbone.History, {location: location}); Backbone.history.start({hashChange: false, root: '/root/'}); location.assign = function(pathname) { assert.strictEqual(pathname, '/root/fragment'); }; Backbone.history.navigate('/fragment'); });
QUnit.test('roots with regex characters', function(assert) { assert.expect(1); location.replace('http://example.com/x+y.z/foo'); Backbone.history.stop(); Backbone.history = _.extend(new Backbone.History, {location: location}); var MyRouter = Backbone.Router.extend({ routes: {foo: function() { assert.ok(true); }} }); var myRouter = new MyRouter; Backbone.history.start({root: 'x+y.z', pushState: true}); });
async(function*(options) { options = _.extend({ directory: path.resolve(path.join(__dirname, "./prototype")) }, options); let buildSystem = new BuildSystem(options); yield buildSystem.rebuild(); assert.ok((yield fs.stat(path.join(__dirname, "prototype/build/Release/addon.node"))).isFile()); })
QUnit.test('listenTo and stopListening cleaning up references', function(assert) { assert.expect(2); var a = _.extend({}, Backbone.Events); var b = _.extend({}, Backbone.Events); a.listenTo(b, 'all', function(){ assert.ok(true); }); b.trigger('anything'); a.listenTo(b, 'other', function(){ assert.ok(false); }); a.stopListening(b, 'other'); a.stopListening(b, 'all'); assert.equal(_.size(a._listeningTo), 0); });
async(function*(options) { options = _.extend({ directory: path.resolve(path.join(__dirname, "./prototype")), cMakeOptions: { foo: "bar" } }, options); let buildSystem = new BuildSystem(options); let command = yield buildSystem.getConfigureCommand(); assert.notEqual(command.indexOf("-Dfoo=\"bar\""), -1, "custom options added"); })
QUnit.test('#3175 - Urls in the params', function(assert) { assert.expect(1); Backbone.history.stop(); location.replace('http://example.com#login?a=value&backUrl=https%3A%2F%2Fwww.msn.com%2Fidp%2Fidpdemo%3Fspid%3Dspdemo%26target%3Db'); Backbone.history = _.extend(new Backbone.History, {location: location}); var myRouter = new Backbone.Router; myRouter.route('login', function(params) { assert.strictEqual(params, 'a=value&backUrl=https%3A%2F%2Fwww.msn.com%2Fidp%2Fidpdemo%3Fspid%3Dspdemo%26target%3Db'); }); Backbone.history.start(); });
QUnit.test('listenTo and stopListening with event maps', function(assert) { assert.expect(1); var a = _.extend({}, Backbone.Events); var b = _.extend({}, Backbone.Events); a.listenTo(b, {change: function(){ assert.ok(true); }}); b.trigger('change'); a.listenTo(b, {change: function(){ assert.ok(false); }}); a.stopListening(); b.trigger('change'); });
QUnit.test('roots with unicode characters', function(assert) { assert.expect(1); location.replace('http://example.com/®ooτ/foo'); Backbone.history.stop(); Backbone.history = _.extend(new Backbone.History, {location: location}); var MyRouter = Backbone.Router.extend({ routes: {foo: function() { assert.ok(true); }} }); var myRouter = new MyRouter; Backbone.history.start({root: '®ooτ', pushState: true}); });