-
Notifications
You must be signed in to change notification settings - Fork 13
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
1 parent
8422547
commit e9a6051
Showing
6 changed files
with
4,239 additions
and
1,300 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Run Tests on PR | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18" | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run tests | ||
run: npm test |
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,2 +1,3 @@ | ||
node_modules | ||
.DS_Store | ||
.DS_Store | ||
testProject |
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,37 @@ | ||
const execSync = require('child_process').execSync; | ||
|
||
const packageJson = require('../package.json'); | ||
|
||
function executeCommand(command) { | ||
return execSync(command, { encoding: 'utf8' }); | ||
} | ||
|
||
describe('bin/static CLI', () => { | ||
it('should return version', () => { | ||
const output = executeCommand('./bin/static --version'); | ||
expect(output.trim()).toBe(packageJson.version); | ||
}); | ||
|
||
it('should create a new project', () => { | ||
process.env.NODE_ENV = 'test'; | ||
const output = executeCommand('./bin/static new testProject'); | ||
const expectedOutput = [ | ||
"New setup initialized", | ||
"Downloading static starter template", | ||
"Finished downloading template", | ||
"Extracting template zip file", | ||
"Finished unzipping", | ||
"New site available inside testProject folder" | ||
].join('\n'); | ||
expect(output.trim()).toBe(expectedOutput); | ||
}); | ||
|
||
it('should build project', () => { | ||
const output = executeCommand('cd testProject; ../bin/static build relative'); | ||
const expectedOutput = [ | ||
"Contents from the public folder have been moved to the _site folder.", | ||
"Successfully built your new static website 🤘", | ||
].join('\n'); | ||
expect(output.trim()).toBe(expectedOutput); | ||
}); | ||
}); |
Oops, something went wrong.