Skip to content

Commit

Permalink
feat: scaffolded basic presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed May 26, 2021
1 parent ccae4f4 commit 8637d4f
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 12 deletions.
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@cucumber/cucumber": "7.2.1",
"@form8ion/babel-preset": "1.6.59",
"@form8ion/commitlint-config": "1.0.19",
"@form8ion/core": "1.4.2",
"@form8ion/eslint-config": "1.7.18",
"@form8ion/eslint-config-cucumber": "1.4.0",
"@form8ion/eslint-config-mocha": "1.2.12",
Expand Down
7 changes: 0 additions & 7 deletions src/canary-test.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {default as scaffold} from './scaffold';
export {default as scaffold} from './scaffolder';
3 changes: 0 additions & 3 deletions src/scaffold.js

This file was deleted.

33 changes: 33 additions & 0 deletions src/scaffolder-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {promises as fs} from 'fs';
import {assert} from 'chai';
import sinon from 'sinon';
import any from '@travi/any';
import scaffold from './scaffolder';

suite('scaffolder', () => {
let sandbox;

setup(() => {
sandbox = sinon.createSandbox();

sandbox.stub(fs, 'writeFile');
});

teardown(() => sandbox.restore());

test('that the presentation is scaffolded', async () => {
const projectRoot = any.string();

const {scripts} = await scaffold({projectRoot});

assert.calledWith(fs.writeFile, `${projectRoot}/slides.md`, '');
assert.deepEqual(
scripts,
{
dev: 'slidev',
build: 'slidev build',
export: 'slidev export'
}
);
});
});
13 changes: 13 additions & 0 deletions src/scaffolder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {promises as fs} from 'fs';

export default async function ({projectRoot}) {
await fs.writeFile(`${projectRoot}/slides.md`, '');

return {
scripts: {
dev: 'slidev',
build: 'slidev build',
export: 'slidev export'
}
};
}
2 changes: 2 additions & 0 deletions test/integration/features/scaffolder.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ Feature: Scaffolder

Scenario: Scaffold
When the project is scaffolded
Then the expected files are generated
And the scripts are defined
2 changes: 1 addition & 1 deletion test/integration/features/step_definitions/common-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ When('the project is scaffolded', async function () {
node_modules: stubbedNodeModules
});

await scaffold({projectRoot: process.cwd()});
this.results = await scaffold({projectRoot: process.cwd()});
});
18 changes: 18 additions & 0 deletions test/integration/features/step_definitions/scaffold-steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {Then} from '@cucumber/cucumber';
import {assert} from 'chai';
import {fileExists} from '@form8ion/core';

Then('the expected files are generated', async function () {
assert.isTrue(await fileExists(`${process.cwd()}/slides.md`));
});

Then('the scripts are defined', async function () {
assert.deepEqual(
this.results.scripts,
{
dev: 'slidev',
build: 'slidev build',
export: 'slidev export'
}
);
});

0 comments on commit 8637d4f

Please sign in to comment.