Skip to content

Commit cd905bc

Browse files
authored
Merge pull request #21 from adobe/dev
New Contributor Folder pattern, initial tests
2 parents ce01298 + 5deb8a3 commit cd905bc

File tree

5 files changed

+48
-28
lines changed

5 files changed

+48
-28
lines changed

package-lock.json

+10-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"test": "react-scripts test",
2525
"eject": "react-scripts eject",
2626
"predeploy": "npm run build",
27-
"deploy": "gh-pages -d build"
27+
"deploy": "gh-pages -d build",
28+
"testAction": "jest scripts/tests"
2829
},
2930
"eslintConfig": {
3031
"extends": [
@@ -49,6 +50,7 @@
4950
"@actions/github": "^6.0.0",
5051
"args": "^5.0.3",
5152
"gh-pages": "^6.1.1",
53+
"jest": "^27.5.1",
5254
"marked": "^14.0.0",
5355
"react-router-dom": "^6.25.1",
5456
"yaml": "^2.5.0"

scripts/tests/utils.test.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const underTest = require('../utils');
2+
const path = require('path');
3+
const fs = require('fs');
4+
5+
jest.mock('path');
6+
jest.mock('fs');
7+
8+
test('Derives proper repository name', () => {
9+
path.dirname.mockReturnValue('/public/features/owner/feature-contribution');
10+
const repo = underTest.deriveRepo('file.md');
11+
expect(repo).toBe('https://github.com/owner/feature-contribution');
12+
});
13+
14+
test('Reads file contents', () => {
15+
fs.readFileSync.mockReturnValue('file contents');
16+
const contents = underTest.getContents('file.md');
17+
expect(contents).toBe('file contents');
18+
});
19+
20+
test('Get changed files', () => {
21+
fs.readFileSync.mockReturnValue('["file1.md","file2.md"]');
22+
const files = underTest.getFilesList('files.json');
23+
expect(files).toEqual(["file1.md", "file2.md"]);
24+
});

scripts/utils.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const { dir } = require('console');
21
const fs = require('fs');
32
const path = require('path');
43

@@ -34,13 +33,7 @@ const deriveRepo = (file) => {
3433
let directory = path.dirname(file);
3534
const featuresRegEx = /(\/|.*\/|\.\.\/)?features\//g;
3635
directory = directory.replaceAll(featuresRegEx, '');
37-
const segments = [
38-
directory.slice(0, directory.indexOf('-')),
39-
directory.slice(directory.indexOf('-') + 1)
40-
];
41-
console.log(segments);
42-
43-
return `https://github.com/${segments[0]}/${segments[1]}`;
36+
return `https://github.com/${directory}`;
4437
}
4538

4639
exports.deriveRepo = deriveRepo;

yarn.lock

+10-10
Original file line numberDiff line numberDiff line change
@@ -5854,9 +5854,9 @@ ci-info@^3.2.0:
58545854
integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==
58555855

58565856
cjs-module-lexer@^1.0.0:
5857-
version "1.3.1"
5858-
resolved "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.3.1.tgz"
5859-
integrity sha512-a3KdPAANPbNE4ZUv9h6LckSl9zLsYOP4MBmhIPkRaeyybt+r4UghLvq+xw/YwUcC1gqylCkL4rdVs3Lwupjm4Q==
5857+
version "1.4.0"
5858+
resolved "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.0.tgz"
5859+
integrity sha512-N1NGmowPlGBLsOZLPvm48StN04V4YvQRL0i6b7ctrVY3epjP/ct7hFLOItz6pDIvRjwpfPxi52a2UWV2ziir8g==
58605860

58615861
clean-css@^5.2.2:
58625862
version "5.3.3"
@@ -8165,9 +8165,9 @@ import-fresh@^3.1.0, import-fresh@^3.2.1:
81658165
resolve-from "^4.0.0"
81668166

81678167
import-local@^3.0.2:
8168-
version "3.1.0"
8169-
resolved "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz"
8170-
integrity sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==
8168+
version "3.2.0"
8169+
resolved "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz"
8170+
integrity sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==
81718171
dependencies:
81728172
pkg-dir "^4.2.0"
81738173
resolve-cwd "^3.0.0"
@@ -9130,7 +9130,7 @@ jest-worker@^28.0.2:
91309130
merge-stream "^2.0.0"
91319131
supports-color "^8.0.0"
91329132

9133-
"jest@^27.0.0 || ^28.0.0", jest@^27.4.3:
9133+
"jest@^27.0.0 || ^28.0.0", jest@^27.4.3, jest@^27.5.1:
91349134
version "27.5.1"
91359135
resolved "https://registry.npmjs.org/jest/-/jest-27.5.1.tgz"
91369136
integrity sha512-Yn0mADZB89zTtjkPJEXwrac3LHudkQMR+Paqa8uxJHCBr9agxztUifWCyiYrjhMPBoUVBjyny0I7XH6ozDr7QQ==
@@ -9807,9 +9807,9 @@ nth-check@^2.0.1:
98079807
boolbase "^1.0.0"
98089808

98099809
nwsapi@^2.2.0:
9810-
version "2.2.10"
9811-
resolved "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.10.tgz"
9812-
integrity sha512-QK0sRs7MKv0tKe1+5uZIQk/C8XGza4DAnztJG8iD+TpJIORARrCxczA738awHrZoHeTjSSoHqao2teO0dC/gFQ==
9810+
version "2.2.12"
9811+
resolved "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.12.tgz"
9812+
integrity sha512-qXDmcVlZV4XRtKFzddidpfVP4oMSGhga+xdMc25mv8kaLUHtgzCDhUxkrN8exkGdTlLNaXj7CV3GtON7zuGZ+w==
98139813

98149814
oargv@^3.4.1:
98159815
version "3.4.10"

0 commit comments

Comments
 (0)