@@ -7,34 +7,66 @@ const codeComplexity = resolve(__dirname, "../src/index.ts");
77const fixture = resolve ( __dirname , "code-complexity-fixture" ) ;
88
99describe ( "code-complexity" , ( ) => {
10- let output ;
10+ context ( "With details, limit and sort" , ( ) => {
11+ it ( "outputs the appropriate values" , ( ) => {
12+ // Given
13+ const command = [
14+ `ts-node ${ codeComplexity } ` ,
15+ fixture ,
16+ `--details` ,
17+ `--limit 10` ,
18+ `--sort complexity`
19+ ] . join ( " " ) ;
1120
12- before ( ( ) => {
13- const command = [
14- `ts-node ${ codeComplexity } ` ,
15- fixture ,
16- `--details` ,
17- `--limit 10` ,
18- `--sort complexity`
19- ] . join ( " " ) ;
21+ // When
22+ const output = execSync ( command , { encoding : "utf8" } ) ;
2023
21- output = execSync ( command , { encoding : "utf8" } ) ;
22- } ) ;
24+ // Then
25+ expect ( output . trim ( ) ) . to . deep . equal (
26+ [
27+ "lib/response.js 142416 (commits: 276, sloc: 516)" ,
28+ "test/app.router.js 54714 (commits: 66, sloc: 829)" ,
29+ "lib/router/index.js 40005 (commits: 105, sloc: 381)" ,
30+ "lib/application.js 32818 (commits: 122, sloc: 269)" ,
31+ "lib/request.js 21746 (commits: 131, sloc: 166)" ,
32+ "test/res.send.js 17822 (commits: 38, sloc: 469)" ,
33+ "test/res.sendFile.js 14674 (commits: 22, sloc: 667)" ,
34+ "test/Router.js 11100 (commits: 25, sloc: 444)" ,
35+ "lib/express.js 7875 (commits: 125, sloc: 63)" ,
36+ "lib/utils.js 7095 (commits: 55, sloc: 129)"
37+ ] . join ( "\n" )
38+ ) ;
39+ } ) ;
40+
41+ context ( "With exclude" , ( ) => {
42+ it ( "outputs the appropriate values" , ( ) => {
43+ // Given
44+ const command = [
45+ `ts-node ${ codeComplexity } ` ,
46+ fixture ,
47+ `--details` ,
48+ `--limit 8` ,
49+ `--sort complexity` ,
50+ `--excludes response,request`
51+ ] . join ( " " ) ;
52+
53+ // When
54+ const output = execSync ( command , { encoding : "utf8" } ) ;
2355
24- it ( "outputs the appropriate values" , ( ) => {
25- expect ( output . trim ( ) ) . to . deep . equal (
26- [
27- "lib/response. js 142416 (commits: 276 , sloc: 516 )",
28- "test/app. router.js 54714 (commits: 66 , sloc: 829 )",
29- "lib/router/index .js 40005 (commits: 105 , sloc: 381 )" ,
30- "lib/application. js 32818 (commits: 122 , sloc: 269 )",
31- "lib/request. js 21746 (commits: 131 , sloc: 166 )",
32- "test/res.send. js 17822 (commits: 38 , sloc: 469 )" ,
33- "test/res.sendFile. js 14674 (commits: 22 , sloc: 667 )",
34- "test/Router .js 11100 (commits: 25 , sloc: 444)" ,
35- "lib/express.js 7875 (commits: 125, sloc: 63)" ,
36- "lib/utils.js 7095 (commits: 55, sloc: 129)"
37- ] . join ( "\n" )
38- ) ;
56+ // Then
57+ expect ( output . trim ( ) ) . to . deep . equal (
58+ [
59+ "test/app.router. js 54714 (commits: 66 , sloc: 829 )",
60+ "lib/ router/index .js 40005 (commits: 105 , sloc: 381 )",
61+ "lib/application .js 32818 (commits: 122 , sloc: 269 )" ,
62+ "test/res.send. js 17822 (commits: 38 , sloc: 469 )",
63+ "test/res.sendFile. js 14674 (commits: 22 , sloc: 667 )",
64+ "test/Router. js 11100 (commits: 25 , sloc: 444 )" ,
65+ "lib/express. js 7875 (commits: 125 , sloc: 63 )",
66+ "lib/utils .js 7095 (commits: 55 , sloc: 129)"
67+ ] . join ( "\n" )
68+ ) ;
69+ } ) ;
70+ } ) ;
3971 } ) ;
4072} ) ;
0 commit comments