小小儁爺
2025-03-06 e9a02d180b91ee7a383d25d5e19853630026b4b1
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
96
97
98
99
100
101
102
103
var expect = require('chai').expect;
var func = require('../lib/utils/gtUtils')
import dayjs from 'dayjs'
 
describe('测试gtUtils.js', function() {
 
  describe('测试getWidthAbout2Times函数', function() {
    it('相同时间 计算结果为0', function() {
      expect(func.getWidthAbout2Times(dayjs(
          '2018-10-10 10:00:00'), dayjs(
        '2018-10-10 10:00:00'), {
          scale: 60,
          cellWidth: 60
        }))
        .to.be.equal(0);
    });
 
    it('数据测试1', function() {
      expect(func.getWidthAbout2Times(dayjs(
        '2018-10-10 10:00:00'), dayjs(
      '2018-10-10 11:00:00'), {
        scale: 60,
        cellWidth: 60
      })).to.equal(60)
    });
 
    it('数据测试2', function() {
      expect(func.getWidthAbout2Times(dayjs(
        '2018-10-10 00:00:00'), dayjs(
      '2018-10-10 01:10:00'), {
        scale: 1,
        cellWidth: 1
      })).to.equal(70)
    });
 
    it('数据测试3', function() {
      expect(func.getWidthAbout2Times(dayjs(
        '2018-10-11 10:00:00'), dayjs(
      '2018-10-11 00:00:00'), {
        scale: 10,
        cellWidth: 10
      })).to.equal(-600)
    });
 
    it('数据测试4', function() {
      expect(func.getWidthAbout2Times(dayjs(
        '2018-10-10 00:00:00'), dayjs(
      '2018-10-10 10:00:00'), {
        scale: 10,
        cellWidth: 60
      })).to.equal(3600)
    });
  });
 
  describe('测试getPositonOffset函数', function() {
    it('相同时间 计算结果为0', function() {
      expect(func.getPositonOffset(dayjs(
          '2018-10-10 10:00:00'), dayjs(
        '2018-10-10 10:00:00'), {
          scale: 60,
          cellWidth: 60
        }))
        .to.be.equal(0);
    });
 
    it('数据测试1', function() {
      expect(func.getPositonOffset(dayjs(
        '2018-10-10 10:00:00'), dayjs(
      '2018-10-10 11:00:00'), {
        scale: 60,
        cellWidth: 60
      })).to.equal(-60)
    });
 
    it('数据测试2', function() {
      expect(func.getPositonOffset(dayjs(
        '2018-10-10 00:00:00'), dayjs(
      '2018-10-10 01:10:00'), {
        scale: 60,
        cellWidth: 60
      })).to.equal(-70)
    });
 
    it('数据测试3', function() {
      expect(func.getPositonOffset(dayjs(
        '2018-10-11 10:00:00'), dayjs(
      '2018-10-11 00:00:00'), {
        scale: 60,
        cellWidth: 60
      })).to.equal(+600)
    });
 
    it('数据测试4', function() {
      expect(func.getPositonOffset(dayjs(
        '2018-10-10 00:00:00'), dayjs(
      '2018-10-10 10:00:00'), {
        scale: 60,
        cellWidth: 60
      })).to.equal(-600)
    });
  });
 
});