Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jonnybojangles/7494287 to your computer and use it in GitHub Desktop.
Save jonnybojangles/7494287 to your computer and use it in GitHub Desktop.
Similar to https://gist.github.com/jonnybojangles/7492609 but this snippet extends the module widget. Good for use across multiple files.
angular.module('widget', []).
factory('widgetVersion', function(){
return {
version: '0.123'
}
});
/*
* Extend widget, sans []s
* */
angular.module('widget').
config(function($provide){
$provide.factory('widgetDate', function(){
return {
date: 'Today'
}
});
});
describe('Test widget', function(){
"use strict";
beforeEach(module('widget'));
/*
* Testing a factory
* */
describe('widgetVersion', function(){
"use strict";
it('Make sure the widget version is correct.', inject(function(widgetVersion){
expect(widgetVersion.version).toBe('0.123');
}));
});
/*
* Testing config (factory)
* */
describe("widgetDate", function () {
"use strict";
it("Does the widget date match our expect value?", inject(function(widgetDate){
expect(widgetDate.date).toBe('Today')
}));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment