How to mock one function from another .js file

How to mock one function from another .js file

Hi All,

I am new to QUnits world. I am trying to mock one function from one .js file which is using one function from another .js file.

Example :

Services.js

function foo (){
      if(......)
            return true;
      else
            return false;

}

Model.js

function bar (){
      var result = services.foo();
      if(result){
            -
            -
      }
      else{
            -
            -
      }
}

Now here, I am writing test cases using QUnits for function bar() and want to mock function foo() from Services.js file.

How can I do this? Any pointers?

Thanks.