Edit in JSFiddle

// Code under test
var MyApp = function () {
    var getFlag = function () {
        return false;
    };

    var reallyImporatantProcess = function () {
        // Do something really important
    };

    var useFlagForSomething = function () {
        if (this.getFlag() === true) {
            return "It was true";
        } else {
            this.reallyImporatantProcess();
            return "It was false";
        }
    };

    return {
        getFlag: getFlag,
        reallyImporatantProcess: reallyImporatantProcess,
        useFlagForSomething: useFlagForSomething
    };
};

// Specs
describe("Testing spies", function () {

    it("Should verify a spy was called", function () {
        // Arrange
        var myApp = new MyApp();
        spyOn(myApp, "reallyImporatantProcess");

        // Act
        var result = myApp.useFlagForSomething();

        // Assert
        expect(myApp.reallyImporatantProcess).toHaveBeenCalled();
        expect(result).toEqual("It was false");
    });

});