samedi 16 juin 2018

Test String.prototype.function Using Mocha/Chai

How could you test a function with Mocha/Chain which is defined as String.prototype.testFunction? For example

Function:

String.prototype.testFunction = (x, y) => {
  return this.z + x + y
}

module.export = String.prototype.testFunction

Use of Function:

"Text".testFunction(1, 2)

From previous experience from testing functions it should be as follows:

const app = require("../index.js")

it('description', function(){
  var variable = "Test".app.testFunction(" ", "text")
  variable.should.equal("Test text")
})

Will this work? Is there a better way to do this?

Thanks

Aucun commentaire:

Enregistrer un commentaire