Skip to content

Instantly share code, notes, and snippets.

@qetr1ck-op
Created September 16, 2015 15:59
Show Gist options
  • Save qetr1ck-op/8ef78320b0af84631e00 to your computer and use it in GitHub Desktop.
Save qetr1ck-op/8ef78320b0af84631e00 to your computer and use it in GitHub Desktop.
module.factory('greeterFactory', function(a) {
function Greeter(a) {
this.greet = function() {
return 'Hello ' + a;
}
}
return new Greeter(a);
});
//or with service
module.service('greeterService', function(a) {
this.greet = function() {
return 'Hello ' + a;
}
});
function Controller(greeterFactory, greeterService) {
expect(greeter instanceof Greeter).toBe(true);
expect(greeter.greet()).toEqual('Hello 123');
const greeter2 = new greeter2;
expect(greeter2 instanceof greeterFactory).toBe(true);
expect(greeter2.greet()).toEqual('Hello 123');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment