Skip to content

Instantly share code, notes, and snippets.

@zachbonham
Last active December 19, 2015 01:28
Show Gist options
  • Save zachbonham/5876001 to your computer and use it in GitHub Desktop.
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.
// 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;
})();
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);
});
});
<!-- 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