File tree Expand file tree Collapse file tree 2 files changed +65
-6
lines changed Expand file tree Collapse file tree 2 files changed +65
-6
lines changed Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+
3
+ const { host } = require ( "../../" ) ;
4
+ const { expect } = require ( "chai" ) ;
5
+
6
+ describe ( "CI/CD host" , ( ) => {
7
+
8
+ if ( typeof window === "undefined" && process . env . GITHUB_ACTIONS === "true" ) {
9
+
10
+ it ( "host.ci should be an object" , ( ) => {
11
+ expect ( host . ci ) . to . be . an ( "object" ) ;
12
+ } ) ;
13
+
14
+ it ( "host.ci.name should be a string" , ( ) => {
15
+ expect ( host . ci . name ) . to . be . a ( "string" ) . with . length . above ( 0 ) ;
16
+ } ) ;
17
+
18
+ it ( "host.ci.pr should be a boolean" , ( ) => {
19
+ expect ( host . ci . name ) . to . be . a ( "boolean" ) ;
20
+ } ) ;
21
+
22
+ it ( "all other properties should be CI/CD constants" , ( ) => {
23
+ let keys = Object . keys ( host . ci ) ;
24
+
25
+ // Remove other properties
26
+ for ( let key of [ "name" , "pr" , "isPR" ] ) {
27
+ keys . splice ( keys . indexOf ( key ) , 1 ) ;
28
+ }
29
+
30
+ for ( let key of keys ) {
31
+ expect ( key ) . to . match ( / [ A - Z ] + ( _ [ A - Z ] + ) * / ) ;
32
+ expect ( host . ci [ key ] ) . to . be . a ( "boolean" , `Invalid CI/CD constant: ${ key } ` ) ;
33
+ }
34
+ } ) ;
35
+
36
+ }
37
+ else {
38
+
39
+ it ( "host.ci should be false" , ( ) => {
40
+ expect ( host . ci ) . to . equal ( false ) ;
41
+ } ) ;
42
+
43
+ }
44
+
45
+ } ) ;
Original file line number Diff line number Diff line change @@ -8,12 +8,26 @@ describe("package exports", () => {
8
8
9
9
function isHostObject ( host ) {
10
10
expect ( host ) . to . be . an ( "object" ) ;
11
- expect ( host ) . to . have . property ( "global" ) ;
12
- expect ( host ) . to . have . property ( "os" ) ;
13
- expect ( host ) . to . have . property ( "env" ) ;
14
- expect ( host ) . to . have . property ( "node" ) ;
15
- expect ( host ) . to . have . property ( "browser" ) ;
16
- expect ( host ) . to . have . property ( "toJSON" ) ;
11
+
12
+ let keys = Object . keys ( host ) ;
13
+
14
+ // Ignore the default and named exports
15
+ for ( let key of [ "default" , "host" ] ) {
16
+ if ( keys . indexOf ( key ) >= 0 ) {
17
+ keys . splice ( keys . indexOf ( key ) , 1 ) ;
18
+ }
19
+ }
20
+
21
+ expect ( keys ) . to . have . same . members ( [
22
+ "global" ,
23
+ "os" ,
24
+ "env" ,
25
+ "ci" ,
26
+ "node" ,
27
+ "browser" ,
28
+ "merge" ,
29
+ "toJSON" ,
30
+ ] ) ;
17
31
18
32
return true ;
19
33
}
You can’t perform that action at this time.
0 commit comments