首页 > 解决方案 > 如何使用业力,茉莉花在AngularJS中测试html页面标题

问题描述

我想在 angularJS 中测试 html 页面标题作为我的单元案例之一。我的控制器的名称是“MainController”。我可以在没有控制器范围的情况下访问标题吗?

describe('Testing Currency App',function(){ beforeEach(module('currencyConv'));

describe('Testing Currency App Controller',function(){

    var scope = {};
    var ctrl;

    beforeEach(inject(function($controller,$rootScope){
        scope = $rootScope.$new();
        ctrl = $controller('MainController', {$scope:scope});
        rootScope = $rootScope;
    }));


    it('should initialise the title',function(){
        expect(scope.title).toBeDefined();
        expect(scope.title).toBe('Angular Currency Converter');
    });
});

});

我是新来的

标签: angularjskarma-jasminetitle

解决方案



推荐阅读