Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

technical/switch to gallinago over testbed #424

Merged
merged 8 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ $ yarn test
Below are some tips to help with running / debugging tests:
- `describe.only` / `it.only`: only runs this block
- `xdescribe` / `xit`: dont run this block
- Uncomment `setup.teardownTestBed()` in a case to see the build output without it getting cleaned up post test run
- Use `new TestBed(true)` get debug output from Greenwood when running tests
- Uncomment `runner.teardown()` in a case to see the build output without it getting cleaned up post test run
- Use `new Runner(true)` get debug output from Greenwood when running tests

> **PLEASE DO NOT COMMIT ANY OF THESE ABOVE CHANGES THOUGH**

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@ls-lint/ls-lint": "^1.9.2",
"chai": "^4.2.0",
"eslint": "^6.8.0",
"gallinago": "^0.3.0",
"glob-promise": "^3.4.0",
"jsdom": "^14.0.0",
"lerna": "^3.16.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,34 @@
* User Workspace
* Greenwood default (src/)
*/
const path = require('path');
const runSmokeTest = require('../../../../../test/smoke-test');
const TestBed = require('../../../../../test/test-bed');
const { getSetupFiles, getOutputTeardownFiles } = require('../../../../../test/utils');
const Runner = require('gallinago').Runner;

describe('Build Greenwood With: ', function() {
const LABEL = 'Empty User Configuration and No Workspace';
let setup;
const LABEL = 'Empty Configuration and Default Workspace';
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = __dirname;
let runner;

before(async function() {
setup = new TestBed();
this.context = await setup.setupTestBed(__dirname);
before(function() {
this.context = {
publicDir: path.join(outputPath, 'public')
};
runner = new Runner();
});

describe(LABEL, function() {
before(async function() {
await setup.runGreenwoodCommand('build');
await runner.setup(outputPath, getSetupFiles(outputPath));
await runner.runCommand(cliPath, 'build');
});

runSmokeTest(['public', 'index'], LABEL);
});

after(function() {
setup.teardownTestBed();
runner.teardown(getOutputTeardownFiles(outputPath));
});
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,30 @@
* Greenwood default
*/
const expect = require('chai').expect;
const TestBed = require('../../../../../test/test-bed');
const path = require('path');
const Runner = require('gallinago').Runner;

describe('Build Greenwood With: ', function() {
let setup;
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = __dirname;
let runner;

before(async function() {
setup = new TestBed();
await setup.setupTestBed(__dirname);
before(function() {
this.context = {
publicDir: path.join(outputPath, 'public')
};
runner = new Runner();
});

describe('Custom Configuration with a bad value for mode', function() {
it('should throw an error that provided mode is not valid', async function() {
try {
await setup.runGreenwoodCommand('build');
await runner.setup(outputPath);
await runner.runCommand(cliPath, 'build');
} catch (err) {
expect(err).to.contain('Error: provided mode "loremipsum" is not supported. Please use one of: ssg, mpa.');
}
});
});

after(function() {
setup.teardownTestBed();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,30 @@
* Greenwood default
*/
const expect = require('chai').expect;
const TestBed = require('../../../../../test/test-bed');
const path = require('path');
const Runner = require('gallinago').Runner;

describe('Build Greenwood With: ', function() {
let setup;
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = __dirname;
let runner;

before(async function() {
setup = new TestBed();
await setup.setupTestBed(__dirname);
this.context = {
publicDir: path.join(outputPath, 'public')
};
runner = new Runner();
});

describe('Custom Configuration with a bad value for optimization', function() {
it('should throw an error that provided optimization is not valid', async function() {
try {
await setup.runGreenwoodCommand('build');
await runner.setup(outputPath);
await runner.runCommand(cliPath, 'build');
} catch (err) {
expect(err).to.contain('Error: provided optimization "loremipsum" is not supported. Please use one of: default, none, static, inline.');
}
});
});

after(function() {
setup.teardownTestBed();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,30 @@
* Greenwood default
*/
const expect = require('chai').expect;
const TestBed = require('../../../../../test/test-bed');
const path = require('path');
const Runner = require('gallinago').Runner;

describe('Build Greenwood With: ', function() {
let setup;
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = __dirname;
let runner;

before(async function() {
setup = new TestBed();
await setup.setupTestBed(__dirname);
this.context = {
publicDir: path.join(outputPath, 'public')
};
runner = new Runner();
});

describe('Custom Configuration with a bad value for Title', function() {
it('should throw an error that title must be a string', async function() {
try {
await setup.runGreenwoodCommand('build');
await runner.setup(outputPath);
await runner.runCommand(cliPath, 'build');
} catch (err) {
expect(err).to.contain('greenwood.config.js title must be a string');
}
});
});

after(function() {
setup.teardownTestBed();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,30 @@
* Greenwood default
*/
const expect = require('chai').expect;
const TestBed = require('../../../../../test/test-bed');
const path = require('path');
const Runner = require('gallinago').Runner;

describe('Build Greenwood With: ', function() {
let setup;
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = __dirname;
let runner;

before(async function() {
setup = new TestBed();
await setup.setupTestBed(__dirname);
this.context = {
publicDir: path.join(outputPath, 'public')
};
runner = new Runner();
});

describe('Custom Configuration with a bad value (absolute path) for Workspace', function() {
it('should throw an error that workspace path must exist', async function() {
try {
await setup.runGreenwoodCommand('build');
await runner.setup(outputPath);
await runner.runCommand(cliPath, 'build');
} catch (err) {
expect(err).to.contain('greenwood.config.js workspace doesn\'t exist!');
}
});
});

after(function() {
setup.teardownTestBed();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,30 @@
* Greenwood default
*/
const expect = require('chai').expect;
const TestBed = require('../../../../../test/test-bed');
const path = require('path');
const Runner = require('gallinago').Runner;

describe('Build Greenwood With: ', function() {
let setup;
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = __dirname;
let runner;

before(async function() {
setup = new TestBed();
await setup.setupTestBed(__dirname);
this.context = {
publicDir: path.join(outputPath, 'public')
};
runner = new Runner();
});

describe('Custom Configuration with a bad value for Workspace', function() {
it('should throw an error that workspace path must be a string', async function() {
try {
await setup.runGreenwoodCommand('build');
await runner.setup(outputPath);
await runner.runCommand(cliPath, 'build');
} catch (err) {
expect(err).to.contain('greenwood.config.js workspace path must be a string');
}
});
});

after(function() {
setup.teardownTestBed();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,26 @@ const { JSDOM } = require('jsdom');
const path = require('path');
const expect = require('chai').expect;
const runSmokeTest = require('../../../../../test/smoke-test');
const TestBed = require('../../../../../test/test-bed');
const { getSetupFiles, getOutputTeardownFiles } = require('../../../../../test/utils');
const Runner = require('gallinago').Runner;

describe('Build Greenwood With: ', function() {
const LABEL = 'Custom Markdown Configuration and Default Workspace';
let setup;
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = __dirname;
let runner;

before(async function() {
setup = new TestBed();

this.context = await setup.setupTestBed(__dirname);
before(function() {
this.context = {
publicDir: path.join(outputPath, 'public')
};
runner = new Runner();
});

describe(LABEL, function() {
before(async function() {
await setup.runGreenwoodCommand('build');
await runner.setup(outputPath, getSetupFiles(outputPath));
await runner.runCommand(cliPath, 'build');
});

runSmokeTest(['public', 'index'], LABEL);
Expand Down Expand Up @@ -77,7 +82,7 @@ describe('Build Greenwood With: ', function() {
});

after(function() {
setup.teardownTestBed();
runner.teardown(getOutputTeardownFiles(outputPath));
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,29 @@
* index.md
*/
const { JSDOM } = require('jsdom');
const path = require('path');
const expect = require('chai').expect;
const TestBed = require('../../../../../test/test-bed');
const path = require('path');
const { getSetupFiles, getOutputTeardownFiles } = require('../../../../../test/utils');
const Runner = require('gallinago').Runner;

describe('Build Greenwood With: ', function() {
const LABEL = 'Custom Markdown Configuration and Custom Workspace';
let setup;
const cliPath = path.join(process.cwd(), 'packages/cli/src/index.js');
const outputPath = __dirname;
let runner;

before(async function() {
setup = new TestBed();

this.context = await setup.setupTestBed(__dirname);
this.context = {
publicDir: path.join(outputPath, 'public')
};
runner = new Runner();
});

describe(LABEL, function() {

before(async function() {
await setup.runGreenwoodCommand('build');
await runner.setup(outputPath, getSetupFiles(outputPath));
await runner.runCommand(cliPath, 'build');
});

describe('Custom Markdown Presets', function() {
Expand All @@ -58,7 +63,7 @@ describe('Build Greenwood With: ', function() {
});

after(function() {
setup.teardownTestBed();
runner.teardown(getOutputTeardownFiles(outputPath));
});

});
Loading