单元测试以查看是否定义了类方法

时间:2016-07-04 15:36:37

标签: unit-testing angular jasmine karma-runner

我只想测试我的类方法是否已定义,例如:

<meta name="viewport" content="width=device-width" />

单元测试......如:

img {
    max-width:100%;
}
@viewport {
    width: extend-to-zoom 980px;
    min-zoom: 0.25;
    max-zoom: 5;
}
body {
    margin:0;
    background:url(../images/bg-body.png) repeat-x left top #a6a6a6;
    font-family:Arial, Helvetica, sans-serif;
}
a {
    outline:none;
}
a img {
    border:0;
    display:block;
}
.background {
    background:url(../images/bg-background.jpg);
    background-color: #696969;
    background-position: 0 100%;
    background-repeat: repeat;
    background-attachment: fixed;
    background-size: cover;
    background-size: 100%;
}

不工作。

1 个答案:

答案 0 :(得分:1)

要测试类实例中方法的存在,它应该是

expect(settingModal.saveForm).toBeDefined()

或者更确切地说,

expect(settingModal.saveForm).toBe(jasmine.any(Function));