-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
167 additions
and
8 deletions.
There are no files selected for viewing
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/features/license/utils/__tests__/cleanLicenseName.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import cleanLicenseName from '../cleanLicenseName' | ||
|
||
describe('cleanLicenseName', () => { | ||
it('should remove .txt and convert to uppercase', () => { | ||
expect(cleanLicenseName('mit.txt')).toEqual('MIT') | ||
}) | ||
}) |
12 changes: 12 additions & 0 deletions
12
src/features/license/utils/__tests__/getLicenseContentInReadme.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import getLicenseContentInReadme from '../getLicenseContentInReadme' | ||
|
||
describe('getLicenseContentInReadme', () => { | ||
it('should return the content of the license section in the readme', () => { | ||
const expectedLicenseContent = | ||
'This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.' | ||
|
||
const licenseContent = getLicenseContentInReadme('MIT') | ||
|
||
expect(licenseContent).toEqual(expectedLicenseContent) | ||
}) | ||
}) |
12 changes: 12 additions & 0 deletions
12
src/features/license/utils/__tests__/getLicenseFilename.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import getLicenseFilename from '../getLicenseFilename' | ||
|
||
describe('getLicenseFilename', () => { | ||
it('should return the path to the license file', () => { | ||
const repositoryPath = '/path/to/repo' | ||
const expectedFilename = '/path/to/repo/LICENSE' | ||
|
||
const filename = getLicenseFilename(repositoryPath) | ||
|
||
expect(filename).toBe(expectedFilename) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import hasProperty from '../hasProperty' | ||
|
||
describe('hasProperty', () => { | ||
it('should return true', () => { | ||
const content = 'foo {{var}} bar' | ||
|
||
expect(hasProperty(content, 'var')).toBe(true) | ||
}) | ||
|
||
it('should return true when template has space', () => { | ||
const content = 'foo {{ var }} bar' | ||
|
||
expect(hasProperty(content, 'var')).toBe(true) | ||
}) | ||
|
||
it('should return false when no variable', () => { | ||
const content = 'foo bar' | ||
|
||
expect(hasProperty(content, 'var')).toBe(false) | ||
}) | ||
|
||
it('should return false when variable with wrong name', () => { | ||
const content = 'foo {{var2}} bar' | ||
|
||
expect(hasProperty(content, 'var')).toBe(false) | ||
}) | ||
}) |
2 changes: 1 addition & 1 deletion
2
...s/license/utils/properties/hasProperty.ts → src/features/license/utils/hasProperty.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const hasProperty = (content: string, property: string) => | ||
content.includes(`{{ ${property} }}`) | ||
Boolean(content.match(new RegExp(`{{[ ]*${property}[ ]*}}`))) | ||
|
||
export default hasProperty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import npm from '../npm' | ||
|
||
describe('npm', () => { | ||
describe('getConfigFile', () => { | ||
it('should return package-lock.yaml', () => { | ||
expect(npm.getConfigFile()).toBe('package-lock.yaml') | ||
}) | ||
}) | ||
|
||
describe('getCommand', () => { | ||
it('should return npm install', () => { | ||
expect(npm.getCommand('install')).toBe('npm install') | ||
}) | ||
|
||
it('should return npm test', () => { | ||
expect(npm.getCommand('test')).toBe('npm test') | ||
}) | ||
|
||
it('should return npm start', () => { | ||
expect(npm.getCommand('start')).toBe('npm start') | ||
}) | ||
|
||
it('should return npm run format', () => { | ||
expect(npm.getCommand('format')).toBe('npm run format') | ||
}) | ||
}) | ||
}) |
27 changes: 27 additions & 0 deletions
27
src/features/package/packageManager/__tests__/pnpm.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pnpm from '../pnpm' | ||
|
||
describe('pnpm', () => { | ||
describe('getConfigFile', () => { | ||
it('should return pnpm-lock.yaml', () => { | ||
expect(pnpm.getConfigFile()).toBe('pnpm-lock.yaml') | ||
}) | ||
}) | ||
|
||
describe('getCommand', () => { | ||
it('should return pnpm install', () => { | ||
expect(pnpm.getCommand('install')).toBe('pnpm install') | ||
}) | ||
|
||
it('should return pnpm test', () => { | ||
expect(pnpm.getCommand('test')).toBe('pnpm test') | ||
}) | ||
|
||
it('should return pnpm start', () => { | ||
expect(pnpm.getCommand('start')).toBe('pnpm start') | ||
}) | ||
|
||
it('should return pnpm format', () => { | ||
expect(pnpm.getCommand('format')).toBe('pnpm format') | ||
}) | ||
}) | ||
}) |
27 changes: 27 additions & 0 deletions
27
src/features/package/packageManager/__tests__/yarn.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import yarn from '../yarn' | ||
|
||
describe('yarn', () => { | ||
describe('getConfigFile', () => { | ||
it('should return yarn.lock', () => { | ||
expect(yarn.getConfigFile()).toBe('yarn.lock') | ||
}) | ||
}) | ||
|
||
describe('getCommand', () => { | ||
it('should return yarn install', () => { | ||
expect(yarn.getCommand('install')).toBe('yarn install') | ||
}) | ||
|
||
it('should return yarn test', () => { | ||
expect(yarn.getCommand('test')).toBe('yarn test') | ||
}) | ||
|
||
it('should return yarn start', () => { | ||
expect(yarn.getCommand('start')).toBe('yarn start') | ||
}) | ||
|
||
it('should return yarn format', () => { | ||
expect(yarn.getCommand('format')).toBe('yarn format') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import PackageManager from './PackageManager' | ||
|
||
const commandsWithoutRun = ['start', 'test', 'install'] | ||
|
||
const npm: PackageManager = { | ||
getConfigFile: () => 'package-lock.yaml', | ||
getCommand: (script: string) => | ||
['start', 'test'].includes(script) ? `npm ${script}` : `pnpm run ${script}`, | ||
commandsWithoutRun.includes(script) ? `npm ${script}` : `npm run ${script}`, | ||
} | ||
|
||
export default npm |
10 changes: 10 additions & 0 deletions
10
src/features/package/utils/__tests__/getPackageConfigFilename.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import getPackageConfigFilename from '../getPackageConfigFilename' | ||
|
||
describe('getPackageConfigFilename', () => { | ||
it('should return the package.json path', () => { | ||
const repositoryPath = '/path/to/repository' | ||
const expectedFilename = '/path/to/repository/package.json' | ||
|
||
expect(getPackageConfigFilename(repositoryPath)).toBe(expectedFilename) | ||
}) | ||
}) |
2 changes: 1 addition & 1 deletion
2
...res/package/__tests__/setProperty.test.ts → ...ckage/utils/__tests__/setProperty.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/features/pullRequestTemplate/utils/__tests__/getPullRequestTemplateFilename.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import getPullRequestTemplateFilename from '../getPullRequestTemplateFilename' | ||
|
||
describe('getPullRequestTemplateFilename', () => { | ||
it('should return the path to the pull request template file', () => { | ||
const repositoryPath = '/path/to/repo' | ||
const expectedFilename = '/path/to/repo/.github/PULL_REQUEST_TEMPLATE.md' | ||
|
||
const filename = getPullRequestTemplateFilename(repositoryPath) | ||
|
||
expect(filename).toBe(expectedFilename) | ||
}) | ||
}) |