简体   繁体   English

摩卡/打字稿

[英]Mocha / Typescript

How would I write a basic test class to compare the value of two numbers, to test a minimum value validation rule I wrote. 我将如何编写基本的测试类以比较两个数字的值,以测试我编写的最小值验证规则。 For example if the number I give is 10, I need to assert that a 9 "falls below the minimum value" while if the number is 11, then it is acceptable. 例如,如果我给出的数字是10,我需要断言9“下降到最小值以下”,而如果数字是11,则可以接受。

Here is a function that should to do the check; 这是应该进行检查的功能; If variable is greater that 10, the test passes, otherwise the test fails. 如果variable大于10,则测试通过,否则测试失败。

var assert = require('assert');
var variable = 11;
describe('comparison', function() {
  describe('#functionName()', function() {
    it('should return true when the variable is greater than 10', function() {
      assert.equal(true, variable > 10);
    });
  });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM