Last active
December 19, 2015 01:28
-
-
Save zachbonham/5876001 to your computer and use it in GitHub Desktop.
Example WInJS class declaration which works from within project, but not from within spec. Spec throws an exception "TypeError: Object doesn't support property or method 'print'" when I try to call print(). I notice this is also true when I try to call a method of ViewModel.LogIn.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// if I change to export module, then I can access without any problems? | |
var PrintModule = (function () { | |
var PrintContext = function () { | |
var self = this; | |
self.isRegistered = function () { | |
return true; | |
} | |
}; | |
return PrintContext; | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("Printing", function () { | |
it("Registers for Print contract", function () { | |
var context = new Print.Context(); | |
// throws exception when trying to access member function print() | |
expect(context.print()).toEqual(true); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- snippet showing how referencing print.js --> | |
<script type="text/javascript" src="../WorkItemGlass.Metro.UI/js/viewModels.js"></script> | |
<script type="text/javascript" src="../WorkItemGlass.Metro.UI/js/print.js"></script> | |
<script type="text/javascript" src="../WorkItemGlass.Metro.UI\pages\login\loginViewModel.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment