jeudi 9 juillet 2015

How can I test an object with properties with random values?

I'm setting a unit test and I'm mocking an an object (client) which has a _request method which expects an object and a callback function. The object param has a couple of properties with random values:

var clientMock = sandbox.mock(client);   // client is defined up somewhere
clientMock
  .expects('_request')
  .withArgs({
    method: 'POST',
    form: {
      commands: [{
        type: "item_add",
        temp_id: '???',       // <== This is random value
        uuid: '???',          // <== Another random value
        args: { ... }
      }]
    }
  }, sinon.match.func);

How can set a test for that?

Thanks.

Aucun commentaire:

Enregistrer un commentaire