test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once().yieldsTo('success', {
      message: 'Hello'
    });
    window.ipc.foo.bar();
    $mock.verify();
  });
});

test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once().yieldsTo('success', {
      message: 'Hello'
    });
    window.ipc.foo.bar();
    $mock.verify();
  });
});

test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once().yieldsTo('success', {
      message: 'Hello'
    });
    window.ipc.foo.bar();
    $mock.verify();
  });
});

test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once().yieldsTo('success', {
      message: 'Hello'
    });
    window.ipc.foo.bar();
    $mock.verify();
  });
});

test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once().yieldsTo('success', {
      message: 'Hello'
    });
    window.ipc.foo.bar();
    $mock.verify();
  });
});

test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once().yieldsTo('success', {
      message: 'Hello'
    });
    window.ipc.foo.bar();
    $mock.verify();
  });
});

test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    
    $mock.expects('ajax').once().yieldsTo('success', {
      message: 'Hello'
    });
    $mock.expects('get').once();
    window.ipc.foo.bar();
    $mock.verify();
  });
});

test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once().yieldsTo('success', {
      message: 'Hello'
    });
    window.ipc.foo.bar();
    $mock.verify();
  });
});

test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once()
      .withArgs(sinon.match({
        type: 'POST'
      }))
      .yieldsTo('success', {
        message: 'Hello'
      });
    window.ipc.foo.bar();
    $mock.verify();
  });
});

test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once()
      .withArgs(sinon.match({
        type: 'POST',
        url: '/foo',
        data: sinon.match({ foo: 'bar' })
      }))
      .yieldsTo('success', {
        message: 'Hello'
      });
    window.ipc.foo.bar();
    $mock.verify();
  });
});

test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once().yieldsTo('success', {
      message: 'Hello'
    });
    window.ipc.foo.bar();
    $mock.verify();
  });
});
test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once().yieldsTo('success', {
      message: 'Hello'
    });
    var $node = {
      text: function() {},
      show: function() {}
    };
    // text() will return $node to allow method chaining
    sinon.stub($node, 'text').returns($node);
    sinon.stub($node, 'show');
    // Force $() to return our $node stub
    sinon.stub(window, '$').returns($node);
    window.ipc.foo.bar();
    $mock.verify();
  });
});
test.js
describe('window.ipc.foo.bar()', function() {
  it('should POST somewhere and show a message', function() {
    var $mock = sinon.mock(jQuery);
    $mock.expects('ajax').once().yieldsTo('success', {
      message: 'Hello'
    });
    var $node = {
      text: function() {},
      show: function() {}
    };
    // text() will return $node to allow method chaining
    sinon.stub($node, 'text').returns($node);
    sinon.stub($node, 'show');
    // We can stub window.$ (i.e. $) so that it returns $node
    sinon.stub(window, '$').returns($node);
    window.ipc.foo.bar();
    
    sinon.assert.calledOnce($node.show);
    sinon.assert.calledOnce($node.text);
    sinon.assert.calledWith($node.text, 'Hello');
    $mock.verify();
  });
});
package.json
{
  "name": "foo-project",
  "description": "For fooing.",
  "version": "0.0.1",
  "dependencies": {},
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-cli": "~0.1.11",
    "grunt-karma": "~0.7.1",
    "karma-mocha": "~0.1.0",
    "karma-chai": "~0.0.1",
    "karma-sinon": "~0.0.1",
    "load-grunt-tasks": "~0.2.0"
  }
}

Gruntfile.js
module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt);
  grunt.initConfig({
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    }
  });
  grunt.registerTask('default', ['karma']);
};
karma.conf.js
module.exports = function(config) {
  config.set({
    basePath: '',
    frameworks: ['mocha', 'chai', 'sinon'],
    files: [
        'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js',
        'lib/*.js',
        'tests/*.js'
    ],
    browsers: ['PhantomJS']
  });
};
package.json
{
  "name": "foo-project",
  "description": "For fooing.",
  "version": "0.0.1",
  "dependencies": {},
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-cli": "~0.1.11",
    "grunt-karma": "~0.7.1",
    "karma-mocha": "~0.1.0",
    "karma-chai": "~0.0.1",
    "karma-sinon": "~0.0.1",
    "load-grunt-tasks": "~0.2.0"
  }
}
package.json
{
  "name": "foo-project",
  "description": "For fooing.",
  "version": "0.0.1",
  "dependencies": {},
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-cli": "~0.1.11",
    "grunt-karma": "~0.7.1",
    "karma-mocha": "~0.1.0",
    "karma-chai": "~0.0.1",
    "karma-sinon": "~0.0.1",
    "load-grunt-tasks": "~0.2.0",
    "grunt-contrib-jshint": "~0.6.3"
  }
}
package.json
{
  "name": "foo-project",
  "description": "For fooing.",
  "version": "0.0.1",
  "dependencies": {},
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-cli": "~0.1.11",
    "grunt-karma": "~0.7.1",
    "karma-mocha": "~0.1.0",
    "karma-chai": "~0.0.1",
    "karma-sinon": "~0.0.1",
    "load-grunt-tasks": "~0.2.0",
    "grunt-contrib-jshint": "~0.6.3",
    "karma-junit-reporter": "~0.1.0"
  }
}
package.json
{
  "name": "foo-project",
  "description": "For fooing.",
  "version": "0.0.1",
  "dependencies": {},
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-cli": "~0.1.11",
    "grunt-karma": "~0.7.1",
    "karma-mocha": "~0.1.0",
    "karma-chai": "~0.0.1",
    "karma-sinon": "~0.0.1",
    "load-grunt-tasks": "~0.2.0",
    "grunt-contrib-jshint": "~0.6.3",
    "karma-junit-reporter": "~0.1.0",
    "karma-coffee-preprocessor": "~0.1.0"
  }
}