Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shouzhouServer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjinjing
shouzhouServer
Commits
0d6eba20
Commit
0d6eba20
authored
Jul 05, 2024
by
Leo Zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加测试文件
parent
ee91747d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
407 additions
and
0 deletions
+407
-0
leftStrategies.test.ts
src/__test__/leftStrategies.test.ts
+182
-0
midStrategies.test.ts
src/__test__/midStrategies.test.ts
+48
-0
rightStrategies.test.ts
src/__test__/rightStrategies.test.ts
+177
-0
No files found.
src/__test__/leftStrategies.test.ts
0 → 100644
View file @
0d6eba20
import
{
gateStatusStrategy
}
from
"../biz/strategies/left/gateStatusStrategy"
;
import
{
guchengLoadStrategy
}
from
"../biz/strategies/left/guchengLoadStrategy"
;
import
{
DataExtractor
}
from
"../util/dataExtractor"
;
import
{
sightVisitorFlowByDayStrategy
}
from
"../biz/strategies/left/sightVisitorFlowByDayStrategy"
;
import
{
sightVisitorFlowByHourStrategy
}
from
"../biz/strategies/left/sightVisitorFlowPerHourStrategy"
;
import
{
totalVisitorFlowByHourStrategy
}
from
"../biz/strategies/left/totalVisitorFlowByHourStrategy"
;
import
{
totalVisitorFlowStrategy
}
from
"../biz/strategies/left/totalVisitorFlowStrategy"
;
import
{
testDateError
,
testSightError
,
testStrategy
}
from
"./utils"
;
describe
(
'gateStatusTest'
,
()
=>
{
const
de
=
DataExtractor
.
getInstance
();
it
(
'should be of size 4'
,
()
=>
{
const
strategy
=
new
gateStatusStrategy
();
strategy
.
execute
();
expect
(
strategy
.
getGateStatusMap
().
size
).
toBe
(
4
);
});
it
(
'status should be one of 正常, 拥挤, 顺畅'
,
()
=>
{
const
strategy
=
new
gateStatusStrategy
();
strategy
.
execute
();
expect
(
strategy
.
getGateStatusMap
().
forEach
((
value
,
key
)
=>
{
expect
(
value
).
toMatch
(
/正常|拥挤|顺畅/
);
}));
});
});
describe
(
'guchengLoadTest'
,
()
=>
{
it
(
'load should be one of 正常, 拥挤, 顺畅'
,
()
=>
{
const
strategy
=
new
guchengLoadStrategy
();
expect
(
strategy
.
execute
()).
toMatch
(
/正常|拥挤|顺畅/
);
});
});
describe
(
'sightVisitorFlowByDay test'
,
()
=>
{
const
strategy
=
new
sightVisitorFlowByDayStrategy
();
it
(
'should throw an error if date parameter is missing'
,
()
=>
{
testDateError
(
strategy
);
});
it
(
'should return the correct values'
,
()
=>
{
const
mockParams
=
{
query
:
{
date
:
'2023-07-01'
}
};
const
truthValue
=
{
"八公山森林公园"
:
8
,
"孔庙"
:
3
,
"安丰塘(芍跛)"
:
4
,
"安徽楚文化博物馆"
:
5
,
"安徽第一面党旗纪念园"
:
6
,
"寿州古城游客中心"
:
6
,
"报恩寺"
:
7
,
"楚玉阁"
:
3
,
"汐熙阁"
:
6
,
"清真寺"
:
5
,
"珍珠泉"
:
6
,
"迎辉茶馆"
:
4
,
"随缘堂(周易)"
:
4
}
const
res
=
strategy
.
execute
(
mockParams
);
const
actualData
=
{};
for
(
const
key
in
res
)
{
if
(
res
.
hasOwnProperty
(
key
))
{
actualData
[
key
]
=
res
[
key
].
count
;
}
}
expect
(
actualData
).
toEqual
(
truthValue
);
});
});
describe
(
'sightVisitorFlowByHour test'
,
()
=>
{
const
strategy
=
new
sightVisitorFlowByHourStrategy
();
it
(
'should throw an error if date and sight parameters are missing'
,
()
=>
{
testSightError
(
strategy
);
});
it
(
'should return the correct value'
,
()
=>
{
const
mockParams
=
{
query
:
{
date
:
'2023-07-01'
,
sight
:
'安徽第一面党旗纪念园'
}
};
const
truthValue
=
{
'0'
:
0
,
'1'
:
0
,
'2'
:
0
,
'3'
:
0
,
'4'
:
0
,
'5'
:
1
,
'6'
:
0
,
'7'
:
0
,
'8'
:
0
,
'9'
:
1
,
'10'
:
0
,
'11'
:
2
,
'12'
:
0
,
'13'
:
0
,
'14'
:
0
,
'15'
:
0
,
'16'
:
0
,
'17'
:
0
,
'18'
:
0
,
'19'
:
0
,
'20'
:
1
,
'21'
:
1
,
'22'
:
0
,
'23'
:
0
};
testStrategy
(
strategy
,
mockParams
,
truthValue
);
});
})
describe
(
'totalVisitorFlowByHour test'
,
()
=>
{
const
strategy
=
new
totalVisitorFlowByHourStrategy
();
it
(
'should throw an error if date parameter is missing'
,
()
=>
{
testDateError
(
strategy
);
});
it
(
'should get the correct values'
,
()
=>
{
const
mockParams
=
{
query
:
{
date
:
'2023-07-01'
,
}
};
const
truthValue
=
{
"0"
:
1
,
"1"
:
2
,
"2"
:
2
,
"3"
:
3
,
"4"
:
1
,
"5"
:
2
,
"6"
:
3
,
"7"
:
3
,
"8"
:
4
,
"9"
:
4
,
"10"
:
1
,
"11"
:
3
,
"12"
:
2
,
"13"
:
2
,
"14"
:
3
,
"15"
:
4
,
"16"
:
6
,
"17"
:
5
,
"18"
:
2
,
"19"
:
4
,
"20"
:
4
,
"21"
:
3
,
"22"
:
1
,
"23"
:
2
}
testStrategy
(
strategy
,
mockParams
,
truthValue
);
})
});
describe
(
'totalVisitorFlow test'
,
()
=>
{
const
strategy
=
new
totalVisitorFlowStrategy
();
it
(
'should throw an error if date parameter is missing'
,
()
=>
{
testDateError
(
strategy
);
});
it
(
'should return the right result'
,
()
=>
{
const
mockParams
=
{
query
:
{
date
:
'2023-07-01'
,
}
};
const
truthValue
=
{
total
:
67
,
'老人'
:
19
,
'学生'
:
13
,
'儿童'
:
22
,
'其他'
:
13
}
testStrategy
(
strategy
,
mockParams
,
truthValue
);
})
});
\ No newline at end of file
src/__test__/midStrategies.test.ts
0 → 100644
View file @
0d6eba20
import
{
currentEventStrategy
}
from
"../biz/strategies/middle/currentEventStrategy"
;
import
{
testDateError
,
testStrategy
}
from
"./utils"
;
import
{
allEventDataStrategy
}
from
"../biz/strategies/middle/eventDataStrategy"
;
import
{
totalEventCountStrategy
}
from
"../biz/strategies/middle/totalEventCountStrategy"
;
describe
(
'currentEvent test'
,
function
()
{
const
strategy
=
new
currentEventStrategy
();
it
(
'should throw an error if date parameter is missing'
,
()
=>
{
testDateError
(
strategy
);
});
it
(
'should return the correct values'
,
()
=>
{
const
mockParams
=
{
query
:
{
date
:
'2023-01-14'
}
};
const
truthValue
=
{
pendingEvents
:
1
,
processedEvents
:
1
}
testStrategy
(
strategy
,
mockParams
,
truthValue
);
});
});
describe
(
'allEventData test'
,
function
()
{
it
(
'should get all data'
,
()
=>
{
const
strategy
=
new
allEventDataStrategy
();
const
truthValue
=
200
;
const
res
=
strategy
.
execute
();
expect
(
res
.
length
).
toBe
(
truthValue
);
});
});
describe
(
'totalEventCount test'
,
function
()
{
it
(
'should get correct result'
,
()
=>
{
const
strategy
=
new
totalEventCountStrategy
();
const
truthValue
=
{
'全部事件'
:
200
,
'处置中'
:
76
,
'已办结'
:
41
,
'已处置'
:
35
,
'待调度'
:
48
}
testStrategy
(
strategy
,
''
,
truthValue
);
})
});
\ No newline at end of file
src/__test__/rightStrategies.test.ts
0 → 100644
View file @
0d6eba20
import
{
eventCategoryCountStrategy
}
from
"../biz/strategies/right/eventCategoryCountStrategy"
;
import
{
testStrategy
,
testYearError
}
from
"./utils"
;
import
{
eventMonthDistributionStrategy
}
from
"../biz/strategies/right/eventMonthDistributionStrategy"
;
import
{
eventProcessingTimeStrategy
}
from
"../biz/strategies/right/eventProcessingTimeStrategy"
;
import
{
eventSrcStrategy
}
from
"../biz/strategies/right/eventSrcStrategy"
;
import
{
eventSubCategoryCountStrategy
}
from
"../biz/strategies/right/eventSubCategoryCountStrategy"
;
import
{
eventTimeDistributionStrategy
}
from
"../biz/strategies/right/eventTimeDistributionStrategy"
;
import
{
getEventCountByYearStrategy
}
from
"../biz/strategies/right/getEventCountByYearStrategy"
;
import
{
gridEventCountStrategy
}
from
"../biz/strategies/right/gridEventCountStrategy"
;
const
mockParams
=
{
query
:
{
year
:
'2023'
}
};
describe
(
'eventCategoryCount test'
,
function
()
{
const
strategy
=
new
eventCategoryCountStrategy
();
it
(
'should throw an error if year parameter is missing'
,
()
=>
{
testYearError
(
strategy
);
})
it
(
'should get correct value'
,
()
=>
{
const
truthValue
=
{
'咨询'
:
37
,
'建议'
:
25
,
'投诉'
:
29
,
'指挥调度'
:
22
,
'求助'
:
20
,
'预警系统'
:
20
}
testStrategy
(
strategy
,
mockParams
,
truthValue
)
});
});
describe
(
'eventMonthDistribution test'
,
function
()
{
const
strategy
=
new
eventMonthDistributionStrategy
();
it
(
'should throw an error if year parameter is missing'
,
()
=>
{
testYearError
(
strategy
);
});
it
(
'should get correct results'
,
()
=>
{
const
truthValue
=
{
1
:
20
,
2
:
15
,
3
:
12
,
4
:
13
,
5
:
7
,
6
:
14
,
7
:
13
,
8
:
11
,
9
:
10
,
10
:
11
,
11
:
12
,
12
:
15
}
testStrategy
(
strategy
,
mockParams
,
truthValue
);
});
});
describe
(
'eventProcessingTime test'
,
function
()
{
const
strategy
=
new
eventProcessingTimeStrategy
();
it
(
'should throw an error if year parameter is missing'
,
()
=>
{
testYearError
(
strategy
);
});
it
(
'should get correct results'
,
()
=>
{
const
res
=
strategy
.
execute
(
mockParams
);
expect
(
res
.
调度时长
).
toBeLessThan
(
1.7
);
expect
(
res
.
调度时长
).
toBeGreaterThan
(
0.5
);
expect
(
res
.
处置等待
).
toBeCloseTo
(
5
,
0.01
);
expect
(
res
.
处置时长
).
toBeCloseTo
(
30
,
0.01
);
expect
(
res
.
办结时长
).
toBeCloseTo
(
52.75
,
0.1
)
})
});
describe
(
'eventSrc test'
,
function
()
{
const
strategy
=
new
eventSrcStrategy
();
it
(
'should throw an error if year parameter is missing'
,
()
=>
{
testYearError
(
strategy
);
});
it
(
'should get correct results'
,
()
=>
{
const
truthValue
=
{
'12301热线'
:
25
,
'12345热线'
:
27
,
'指挥调度'
:
24
,
'景管通'
:
27
,
'电话热线'
:
22
,
'舆情平台'
:
28
};
testStrategy
(
strategy
,
mockParams
,
truthValue
);
})
});
describe
(
'eventSubCategoryCount test'
,
function
()
{
const
strategy
=
new
eventSubCategoryCountStrategy
();
it
(
'should throw an error if year parameter is missing'
,
()
=>
{
testYearError
(
strategy
);
});
it
(
'should get correct results'
,
()
=>
{
const
truthValue
=
{
'医疗救助'
:
25
,
'服务质量'
:
29
,
'环境卫生'
:
25
,
'纠纷'
:
26
,
'血族调查'
:
20
,
'设施设备'
:
28
}
testStrategy
(
strategy
,
mockParams
,
truthValue
);
})
});
describe
(
'eventTimeDistribution test'
,
function
()
{
const
strategy
=
new
eventTimeDistributionStrategy
();
it
(
'should throw an error if year parameter is missing'
,
()
=>
{
testYearError
(
strategy
);
});
it
(
'should get correct result'
,
()
=>
{
const
truthValue
=
{
0
:
3
,
1
:
9
,
2
:
6
,
3
:
6
,
4
:
3
,
5
:
5
,
6
:
6
,
7
:
4
,
8
:
11
,
9
:
7
,
10
:
8
,
11
:
5
,
12
:
6
,
13
:
3
,
14
:
7
,
15
:
5
,
16
:
6
,
17
:
10
,
18
:
9
,
19
:
7
,
20
:
5
,
21
:
6
,
22
:
5
,
23
:
11
}
testStrategy
(
strategy
,
mockParams
,
truthValue
);
})
});
describe
(
'getEventCountByYear test'
,
function
()
{
const
strategy
=
new
getEventCountByYearStrategy
();
it
(
'should throw an error if year parameter is missing'
,
()
=>
{
testYearError
(
strategy
);
});
it
(
'should get correct result'
,
()
=>
{
const
truthValue
=
{
'事件总数'
:
153
,
'历史遗留'
:
0
,
'办结率'
:
29
/
153
}
testStrategy
(
strategy
,
mockParams
,
truthValue
);
});
});
describe
(
'gridEventCount test'
,
function
()
{
const
strategy
=
new
gridEventCountStrategy
();
it
(
'should throw an error if year parameter is missing'
,
()
=>
{
testYearError
(
strategy
);
});
it
(
'should give correct result'
,
()
=>
{
const
truthValue
=
{
'八公山景区'
:
65
,
'寿县古城'
:
38
,
'寿州全域'
:
50
}
testStrategy
(
strategy
,
mockParams
,
truthValue
);
})
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment