1
+ const { it } = require ( 'node:test' ) ;
1
2
const path = require ( 'path' ) ;
2
3
const assert = require ( 'assert' ) ;
3
4
const resolveEnvironment = require ( '../src/resolveEnvironment' ) ;
4
5
5
- function testDevEnv ( ) {
6
+ it ( 'resolves the dev environment' , ( ) => {
6
7
const result = resolveEnvironment ( { } ) ;
7
8
assert . equal ( result . beforeSha , '__LATEST__' ) ;
8
9
assert . ok ( / ^ d e v - [ a - z 0 - 9 ] + $ / . test ( result . afterSha ) ) ;
9
10
assert . equal ( result . link , undefined ) ;
10
11
assert . equal ( result . message , undefined ) ;
11
- }
12
+ } ) ;
12
13
13
- function testCircleCIEnv ( ) {
14
+ it ( 'resolves the CircleCI environment' , ( ) => {
14
15
const circleEnv = {
15
16
CI_PULL_REQUEST : 'https://ghe.com/foo/bar/pull/12' ,
16
17
CIRCLE_PROJECT_USERNAME : 'happo' ,
@@ -43,9 +44,9 @@ function testCircleCIEnv() {
43
44
assert . equal ( result . afterSha , 'abcdef' ) ;
44
45
assert . equal ( result . link , 'https://github.com/happo/happo-view/commit/abcdef' ) ;
45
46
assert . ok ( result . message !== undefined ) ;
46
- }
47
+ } ) ;
47
48
48
- function testAzureEnv ( ) {
49
+ it ( 'resolves the Azure environment' , ( ) => {
49
50
const azureEnv = {
50
51
BUILD_SOURCEVERSION : '25826448f15ebcb939804ca769a00ee1df08e10d' ,
51
52
BUILD_REPOSITORY_URI :
@@ -89,9 +90,9 @@ function testAzureEnv() {
89
90
// 'https://github.com/happo/happo-view/commit/abcdef',
90
91
// );
91
92
// assert.ok(result.message !== undefined);
92
- }
93
+ } ) ;
93
94
94
- function testTagMatchingEnv ( ) {
95
+ it ( 'resolves the tag matching environment' , ( ) => {
95
96
const azureEnv = {
96
97
BUILD_SOURCEVERSION : '25826448f15ebcb939804ca769a00ee1df08e10d' ,
97
98
BUILD_REPOSITORY_URI :
@@ -110,9 +111,9 @@ function testTagMatchingEnv() {
110
111
111
112
assert . equal ( result . afterSha , '25826448f15ebcb939804ca769a00ee1df08e10d' ) ;
112
113
assert . equal ( result . beforeSha , '25826448f15ebcb939804ca769a00ee1df08e10d' ) ;
113
- }
114
+ } ) ;
114
115
115
- function testGithubActionsEnvironment ( ) {
116
+ it ( 'resolves the GitHub Actions environment' , ( ) => {
116
117
const githubEnv = {
117
118
GITHUB_SHA : 'ccddffddccffdd' ,
118
119
GITHUB_EVENT_PATH : path . resolve ( __dirname , 'github_pull_request_event.json' ) ,
@@ -163,9 +164,9 @@ function testGithubActionsEnvironment() {
163
164
caughtError . message ,
164
165
'Failed to load GitHub event from the GITHUB_EVENT_PATH environment variable: "non-existing-path"' ,
165
166
) ;
166
- }
167
+ } ) ;
167
168
168
- function testGithubMergeGroupEnvironment ( ) {
169
+ it ( 'resolves the GitHub merge group environment' , ( ) => {
169
170
const githubEnv = {
170
171
GITHUB_SHA : 'ccddffddccffdd' ,
171
172
GITHUB_EVENT_PATH : path . resolve ( __dirname , 'github_merge_group_event.json' ) ,
@@ -178,9 +179,9 @@ function testGithubMergeGroupEnvironment() {
178
179
'https://github.com/Codertocat/Hello-World/commit/ec26c3e57ca3a959ca5aad62de7213c562f8c821' ,
179
180
) ;
180
181
assert . ok ( result . message !== undefined ) ;
181
- }
182
+ } ) ;
182
183
183
- function testTravisEnv ( ) {
184
+ it ( 'resolves the Travis environment' , ( ) => {
184
185
const travisEnv = {
185
186
HAPPO_GITHUB_BASE : 'http://git.hub' ,
186
187
TRAVIS_REPO_SLUG : 'owner/repo' ,
@@ -226,9 +227,9 @@ bdac2595db20ad2a6bf335b59510aa771125526a
226
227
);
227
228
assert.ok(result.message !== undefined);
228
229
*/
229
- }
230
+ } ) ;
230
231
231
- function testHappoEnv ( ) {
232
+ it ( 'resolves the happo environment' , ( ) => {
232
233
const happoEnv = {
233
234
HAPPO_CURRENT_SHA : 'bdac2595db20ad2a6bf335b59510aa771125526a' ,
234
235
HAPPO_PREVIOUS_SHA : 'hhhggg' ,
@@ -267,17 +268,4 @@ function testHappoEnv() {
267
268
assert . equal ( result . afterSha , 'bdac2595db20ad2a6bf335b59510aa771125526a' ) ;
268
269
assert . equal ( result . link , 'link://link' ) ;
269
270
assert . ok ( result . message !== undefined ) ;
270
- }
271
-
272
- function runTest ( ) {
273
- testGithubActionsEnvironment ( ) ;
274
- testGithubMergeGroupEnvironment ( ) ;
275
- testDevEnv ( ) ;
276
- testCircleCIEnv ( ) ;
277
- testTravisEnv ( ) ;
278
- testAzureEnv ( ) ;
279
- testHappoEnv ( ) ;
280
- testTagMatchingEnv ( ) ;
281
- }
282
- runTest ( ) ;
283
- console . log ( 'All tests passed' ) ;
271
+ } ) ;
0 commit comments