angularjs - 茉莉花的功能范围单元测试
问题描述
我对 Angular 和单元测试很陌生,但我需要为我的应用程序做一些事情。我需要的只是一些关于如何做的指导。
下面是我需要测试的代码
var app = angular.module('quizApp', []);
app.directive('quiz', function(quizFactory) {
return {
restrict: 'AE',
scope: {},
templateUrl: 'template.html',
link: function(scope, elem, attrs) {
scope.start = function() {
scope.id = 0;
scope.quizOver = false;
scope.inProgress = true;
scope.getQuestion();
};
scope.reset = function() {
scope.inProgress = false;
scope.score = 0;
}
这是我迄今为止一直在测试的。
describe('$scope.start', function() {
it('Should start the quiz as long as start button is pressed', function() {
$scope.id = 0;
$scope.quizOver = false;
$scope.inProgress = true;
expect(0).toBe(0);
expect(false).not.toBe(true);
expect(true).toBe(true);
});
});
我的测试不起作用,因为我遇到了错误。有谁可以告诉我如何正确地做到这一点?非常感谢
解决方案
推荐阅读
- makefile - 环境变量未在 Makefile 中设置
- javascript - Webpack.config.js 文件缩小 js 和 css。- 使用 webpack 时如何缩小 js 和 css 文件?
- algorithm - 生长顺序确定
- c# - 为什么 ProgressBar 不显示当前值/不刷新?
- node.js - 填充猫鼬后如何执行全文搜索?
- typescript - 打字稿中的猫鼬静态方法
- sql - 根据给定日期的条件及其先前行操作列检索最新行
- python - 如何防止网站内的部分功能使用python selenium运行?
- c - 一个关于 C 中 calloc 和 free 函数的问题
- linux - Docker暴露的网络端口没有到达容器服务