-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into nahuelon/gh-0/reuse-select-account-prompt
- Loading branch information
Showing
14 changed files
with
328 additions
and
195 deletions.
There are no files selected for viewing
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
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
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
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
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,14 +1,45 @@ | ||
import * as path from 'path' | ||
import { isValidProjectDirectory } from '../directory' | ||
import { hasPackageJsonFile, isValidProjectDirectory, readPackageJson } from '../directory' | ||
|
||
describe('isValidProjectDirectory()', () => { | ||
type TestTuple = [string, boolean] | ||
|
||
const cases: TestTuple[] = [ | ||
[path.join(__dirname, './fixtures/valid-dir'), true], | ||
[path.join(__dirname, './fixtures/invalid-dir-1'), false], | ||
[path.join(__dirname, './fixtures/empty-project'), false], | ||
[path.join(__dirname, './fixtures/initiated-project'), true], | ||
[path.join(__dirname, './fixtures/checkly-project'), true], | ||
] | ||
test.each(cases)('directory %s should return valid = %s', (dir, expected) => { | ||
expect(isValidProjectDirectory(dir)).toEqual(expected) | ||
}) | ||
}) | ||
|
||
describe('hasPackageJsonFile()', () => { | ||
type TestTuple = [string, boolean] | ||
const cases: TestTuple[] = [ | ||
[path.join(__dirname, './fixtures/empty-project/'), false], | ||
[path.join(__dirname, './fixtures/initiated-project/'), true], | ||
] | ||
test.each(cases)('directory %s should return valid = %s', (dir, expected) => { | ||
expect(hasPackageJsonFile(dir)).toEqual(expected) | ||
}) | ||
}) | ||
|
||
describe('readPackageJson()', () => { | ||
type TestTuple = [string, string] | ||
const cases: TestTuple[] = [ | ||
[path.join(__dirname, './fixtures/empty-project/'), ''], | ||
[path.join(__dirname, './fixtures/initiated-project/'), 'initiated-project'], | ||
[path.join(__dirname, './fixtures/checkly-project/'), 'checkly-project'], | ||
] | ||
test.each(cases)('directory %s should return name = %s', (dir, expected) => { | ||
try { | ||
expect(readPackageJson(dir).name).toEqual(expected) | ||
} catch (error: any) { | ||
expect(expected).toEqual('') | ||
expect(error.message).toContain('ENOENT: no such file or directory') | ||
} | ||
}) | ||
}) |
23 changes: 23 additions & 0 deletions
23
packages/create-cli/src/utils/__tests__/fixtures/checkly-project/checkly.config.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,23 @@ | ||
import { defineConfig } from 'checkly' | ||
|
||
const config = defineConfig({ | ||
projectName: 'My Project', | ||
logicalId: 'my-project', | ||
repoUrl: 'https://github.com/checkly/checkly-cli', | ||
checks: { | ||
frequency: 10, | ||
locations: ['us-east-1', 'eu-west-1'], | ||
tags: ['mac'], | ||
runtimeId: '2023.02', | ||
checkMatch: '**/__checks__/**/*.check.ts', | ||
browserChecks: { | ||
testMatch: '**/__checks__/**/*.spec.ts', | ||
}, | ||
}, | ||
cli: { | ||
runLocation: 'eu-west-1', | ||
reporters: ['list'], | ||
}, | ||
}) | ||
|
||
export default config |
17 changes: 17 additions & 0 deletions
17
packages/create-cli/src/utils/__tests__/fixtures/checkly-project/package.json
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,17 @@ | ||
{ | ||
"name": "checkly-project", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"type": "commonjs", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"checkly": "latest", | ||
"ts-node": "10.9.1", | ||
"typescript": "4.9.5" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/create-cli/src/utils/__tests__/fixtures/empty-project/README.md
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 @@ | ||
This is an empty project |
Oops, something went wrong.