Skip to content

Commit

Permalink
Add tests and license file
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyiliev committed Sep 29, 2023
1 parent 8422547 commit e9a6051
Show file tree
Hide file tree
Showing 6 changed files with 4,239 additions and 1,300 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/tests.yaml
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.DS_Store
.DS_Store
testProject
37 changes: 37 additions & 0 deletions bin/static.test.js
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);
});
});
Loading

0 comments on commit e9a6051

Please sign in to comment.