angular.module('artists',[]).
factory('Artists',['imageStore',function(imageStore){
return {
thumb:function(){
return imageStore.thumbnailUrl(id)
}
}
}])
beforeEach(module(function($provide){
$provide.value('imageStore',{
thumbnailUrl:function(id){
url='/thumb/'+id
}
})
})
beforeEach(inject(function($inject){
Artists=$inject.get('Artists');
}))
it('return the correct artist thumbnailUrl',function(){
Artists.thumb('1');
expect(url).toBe('/thumbs/1');
})
describe('factory:artists',function(){
var url;
var Artists;
beforeEach(module('artist'));
beforeEach(module(function($provide){
$provide.value('imageStore',{
thumbnailUrl: function (id) {
url = '/thumbs/' + id;
}
})
}));
beforeEach(inject(function($injector){
Artists=$injector.get('Artists')
}))
it('return the correct artist thumbnailUrl',function(){
Artists.thumb('1');
expect(url).toBe('/thumb/1')
})
})
angular.module('hiphop',[])
.factory('deejays',['$rootscope','scratch',function($rootscope,scratch){
return{
originator: 'DJ Kool Herc',
technique: scratch.technique()
}
}])
.factory('scratch',['$rootscope',function($rootscope){
return{
technique:function(){
return 'breakbeat';
}
}
}])
describe('Service: deejays',function(){
beforeEach(module('hiphop'));
var deejays;
beforeEach(inject(function($injector){
deejays=$injector.get('deejays');
}))
beforeEach(inject(function($provide) {
$provide.value('scratch',jasmine.createSpyObj('scratch', ['technique']));
}));
it('should return the correct originator',function(){
expect(deejays.originator).toBe('DJ Kool Herc');
})
})
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有