1- use crate :: rcfile:: Rcfile ;
1+ use { crate :: rcfile:: Rcfile , serde_json :: json } ;
22
33#[ test]
44fn default_format_bugs_is_false ( ) {
@@ -11,3 +11,84 @@ fn default_format_repository_is_false() {
1111 let rcfile = Rcfile :: default ( ) ;
1212 assert ! ( !rcfile. format_repository) ;
1313}
14+
15+ #[ test]
16+ fn detects_v13_dependency_types_in_config ( ) {
17+ let config_json = json ! ( {
18+ "dependencyTypes" : [ "prod" , "dev" ] ,
19+ "versionGroups" : [ ]
20+ } ) ;
21+ let rcfile: Rcfile = serde_json:: from_value ( config_json) . unwrap ( ) ;
22+ assert ! ( rcfile. unknown_fields. contains_key( "dependencyTypes" ) ) ;
23+ }
24+
25+ #[ test]
26+ fn detects_v13_specifier_types_in_config ( ) {
27+ let config_json = json ! ( {
28+ "specifierTypes" : [ "exact" , "range" ] ,
29+ "versionGroups" : [ ]
30+ } ) ;
31+ let rcfile: Rcfile = serde_json:: from_value ( config_json) . unwrap ( ) ;
32+ assert ! ( rcfile. unknown_fields. contains_key( "specifierTypes" ) ) ;
33+ }
34+
35+ #[ test]
36+ fn detects_v13_lint_formatting_in_config ( ) {
37+ let config_json = json ! ( {
38+ "lintFormatting" : true ,
39+ "versionGroups" : [ ]
40+ } ) ;
41+ let rcfile: Rcfile = serde_json:: from_value ( config_json) . unwrap ( ) ;
42+ assert ! ( rcfile. unknown_fields. contains_key( "lintFormatting" ) ) ;
43+ }
44+
45+ #[ test]
46+ fn detects_v13_lint_semver_ranges_in_config ( ) {
47+ let config_json = json ! ( {
48+ "lintSemverRanges" : true ,
49+ "versionGroups" : [ ]
50+ } ) ;
51+ let rcfile: Rcfile = serde_json:: from_value ( config_json) . unwrap ( ) ;
52+ assert ! ( rcfile. unknown_fields. contains_key( "lintSemverRanges" ) ) ;
53+ }
54+
55+ #[ test]
56+ fn detects_v13_lint_versions_in_config ( ) {
57+ let config_json = json ! ( {
58+ "lintVersions" : true ,
59+ "versionGroups" : [ ]
60+ } ) ;
61+ let rcfile: Rcfile = serde_json:: from_value ( config_json) . unwrap ( ) ;
62+ assert ! ( rcfile. unknown_fields. contains_key( "lintVersions" ) ) ;
63+ }
64+
65+ #[ test]
66+ fn detects_multiple_v13_properties_in_config ( ) {
67+ let config_json = json ! ( {
68+ "dependencyTypes" : [ "prod" , "dev" ] ,
69+ "specifierTypes" : [ "exact" ] ,
70+ "lintFormatting" : true ,
71+ "lintSemverRanges" : false ,
72+ "lintVersions" : true ,
73+ "versionGroups" : [ ]
74+ } ) ;
75+ let rcfile: Rcfile = serde_json:: from_value ( config_json) . unwrap ( ) ;
76+ assert_eq ! ( rcfile. unknown_fields. len( ) , 5 ) ;
77+ assert ! ( rcfile. unknown_fields. contains_key( "dependencyTypes" ) ) ;
78+ assert ! ( rcfile. unknown_fields. contains_key( "specifierTypes" ) ) ;
79+ assert ! ( rcfile. unknown_fields. contains_key( "lintFormatting" ) ) ;
80+ assert ! ( rcfile. unknown_fields. contains_key( "lintSemverRanges" ) ) ;
81+ assert ! ( rcfile. unknown_fields. contains_key( "lintVersions" ) ) ;
82+ }
83+
84+ #[ test]
85+ fn valid_v14_config_has_no_unknown_fields ( ) {
86+ let config_json = json ! ( {
87+ "versionGroups" : [ ] ,
88+ "semverGroups" : [ ] ,
89+ "indent" : " " ,
90+ "source" : [ "packages/*/package.json" ]
91+ } ) ;
92+ let rcfile: Rcfile = serde_json:: from_value ( config_json) . unwrap ( ) ;
93+ assert_eq ! ( rcfile. unknown_fields. len( ) , 0 ) ;
94+ }
0 commit comments