永康嘉持电器有限公司前端
小小儁爺
2024-12-25 c6da28cde9dc469ee1e2d4dba4b7234307d9bd5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
var expect = require('chai').expect;
var func = require('../lib/utils/timeLineUtils')
import dayjs from 'dayjs'
 
describe('测试timeLineUtils.js', function() {
  describe('测试calcScalesAbout2Times函数', function() {
    it('相同时间 计算结果为1', function() {
      expect(func.calcScalesAbout2Times(dayjs(
          '2018-10-10 10:00:00'), dayjs('2018-10-10 10:00:00'), ))
        .to.be.equal(1);
    });
 
 
    it('start 在 end 之后 报错', function() {
      expect(() => func.calcScalesAbout2Times(dayjs(
          '2018-10-12 10:00:00'), dayjs('2018-10-10 10:00:00'),
        11)).to.throw('错误的参数顺序');
    });
 
    it('数据测试1', function() {
      expect(func.calcScalesAbout2Times(dayjs(
          '2018-10-10 10:00:00'), dayjs('2018-10-10 11:00:00'),
        10)).to.equal(7)
    });
 
    it('数据测试2', function() {
      expect(func.calcScalesAbout2Times(dayjs(
          '2018-10-10 00:00:00'), dayjs('2018-10-10 11:00:00'),
        60)).to.equal(12)
    });
 
    it('数据测试3', function() {
      expect(func.calcScalesAbout2Times(dayjs(
          '2018-10-10 10:00:00'), dayjs('2018-10-11 00:00:00'),
        60)).to.equal(15)
    });
 
    it('数据测试4', function() {
      expect(func.calcScalesAbout2Times(dayjs(
          '2018-10-10 00:00:00'), dayjs('2018-10-11 00:00:00'),
        60)).to.equal(25)
    });
 
  });
 
  describe('测试getBeginTimeOfTimeLine函数', function() {
    it('测试数据1', function() {
      expect( func.getBeginTimeOfTimeLine(dayjs('2018-10-11 00:00:00')).toString())
        .to.be.equal(dayjs('2018-10-11 00:00:00').toString());
    });
 
    it('测试数据2', function() {
      expect( func.getBeginTimeOfTimeLine(dayjs('2018-10-11 00:00:00'),3).toString())
        .to.be.equal(dayjs('2018-10-11 00:00:00').toString());
    });
 
    it('测试数据3', function() {
      expect( func.getBeginTimeOfTimeLine(dayjs('2018-10-11 00:04:00'),3).toString())
        .to.be.equal(dayjs('2018-10-11 00:03:00').toString());
    });
 
    it('测试数据4', function() {
      expect( func.getBeginTimeOfTimeLine(dayjs('2018-10-11 01:11:00'),10).toString())
        .to.be.equal(dayjs('2018-10-11 01:10:00').toString());
    });
  });
 
  describe('测试validateScale函数', function() {
    it('空值异常', function() {
      expect(() => func.validateScale())
        .to.throw();
    });
 
    it('null 值', function() {
      expect(() => func.validateScale(null))
        .to.throw();
    });
 
    it('undefined 值', function() {
      expect(() => func.validateScale(undefined))
        .to.throw();
    });
 
    it('异常scale 值报错', function() {
      expect(() => func.validateScale())
        .to.throw();
    });
 
    it('正常值', function() {
      expect(func.validateScale(1))
        .to.be.true;
    });
 
  });
});