0.2.0 • Published 8 years ago

kcom v0.2.0

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
8 years ago

kcom

Build Status Coverage Status

Another javascript mock library.

quick impressions

var expect = require('Code').expect;
var mock = require("kcom");

// prepare
var mocked = mock({
  saySomething: function(name){
    return "hello, "+name;
  },
  name: "OO"
});

// mock functions
mock.when(mocked.saySomething("john")).then.answer(function(name){
  return "hi, "+name;
});
expect(mocked.saySomething('john')).to.equal('hi, john');

// mock properties
mock.when(mocked.name).then.return("foo");
expect(mocked.name).to.equal('foo');

// using matchers
var matcher = mock.matcher;
mock.when(mocked.saySomething(matcher.anyString())).then.answer(function(name){
  return 'matched: hi, ' + name;
});
expect(mocked.saySomething('john')).to.equal('matched: hi, john');