-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from form8ion/alpha
- Loading branch information
Showing
13 changed files
with
344 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 +1 @@ | ||
export {default as scaffold} from './scaffold'; | ||
export {default as scaffold} from './scaffolder'; |
This file was deleted.
Oops, something went wrong.
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,65 @@ | ||
import {promises as fs} from 'fs'; | ||
import {assert} from 'chai'; | ||
import sinon from 'sinon'; | ||
import any from '@travi/any'; | ||
import * as testingScaffolder from './testing-scaffolder'; | ||
import scaffold from './scaffolder'; | ||
|
||
suite('scaffolder', () => { | ||
let sandbox; | ||
|
||
setup(() => { | ||
sandbox = sinon.createSandbox(); | ||
|
||
sandbox.stub(fs, 'writeFile'); | ||
sandbox.stub(testingScaffolder, 'default'); | ||
}); | ||
|
||
teardown(() => sandbox.restore()); | ||
|
||
test('that the presentation is scaffolded', async () => { | ||
const projectRoot = any.string(); | ||
const testingDevDependencies = any.listOf(any.word); | ||
const testingScripts = any.simpleObject(); | ||
testingScaffolder.default | ||
.withArgs({projectRoot}) | ||
.resolves({devDependencies: testingDevDependencies, scripts: testingScripts}); | ||
|
||
const {dependencies, devDependencies, scripts} = await scaffold({projectRoot}); | ||
|
||
assert.calledWith( | ||
fs.writeFile, `${projectRoot}/slides.md`, | ||
`--- | ||
theme: default | ||
# random image from a curated Unsplash collection by Anthony | ||
# like them? see https://unsplash.com/collections/94734566/slidev | ||
background: https://source.unsplash.com/collection/94734566/1920x1080 | ||
# apply any windi css classes to the current slide | ||
class: 'text-center' | ||
# https://sli.dev/custom/highlighters.html | ||
highlighter: prism | ||
# some information about the slides, markdown enabled | ||
info: | | ||
## Slidev Starter Template | ||
Presentation slides for developers. | ||
Learn more at [Sli.dev](https://sli.dev) | ||
---` | ||
); | ||
assert.deepEqual(dependencies, ['@slidev/cli', '@slidev/theme-default']); | ||
assert.deepEqual(devDependencies, testingDevDependencies); | ||
assert.deepEqual( | ||
scripts, | ||
{ | ||
dev: 'slidev', | ||
build: 'slidev build', | ||
export: 'slidev export', | ||
...testingScripts | ||
} | ||
); | ||
}); | ||
}); |
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,44 @@ | ||
import {promises as fs} from 'fs'; | ||
import deepmerge from 'deepmerge'; | ||
import scaffoldTesting from './testing-scaffolder'; | ||
|
||
export default async function ({projectRoot}) { | ||
const [testingResults] = await Promise.all([ | ||
scaffoldTesting({projectRoot}), | ||
fs.writeFile( | ||
`${projectRoot}/slides.md`, | ||
`--- | ||
theme: default | ||
# random image from a curated Unsplash collection by Anthony | ||
# like them? see https://unsplash.com/collections/94734566/slidev | ||
background: https://source.unsplash.com/collection/94734566/1920x1080 | ||
# apply any windi css classes to the current slide | ||
class: 'text-center' | ||
# https://sli.dev/custom/highlighters.html | ||
highlighter: prism | ||
# some information about the slides, markdown enabled | ||
info: | | ||
## Slidev Starter Template | ||
Presentation slides for developers. | ||
Learn more at [Sli.dev](https://sli.dev) | ||
---` | ||
) | ||
]); | ||
|
||
return deepmerge( | ||
{ | ||
dependencies: ['@slidev/cli', '@slidev/theme-default'], | ||
scripts: { | ||
dev: 'slidev', | ||
build: 'slidev build', | ||
export: 'slidev export' | ||
} | ||
}, | ||
testingResults | ||
); | ||
} |
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,47 @@ | ||
import deepmerge from 'deepmerge'; | ||
import * as cypressScaffolder from '@form8ion/cypress-scaffolder'; | ||
import * as vulnerableScaffolder from '@form8ion/is-website-vulnerable'; | ||
import sinon from 'sinon'; | ||
import any from '@travi/any'; | ||
import {assert} from 'chai'; | ||
import scaffoldTesting from './testing-scaffolder'; | ||
|
||
suite('testing scaffolder', () => { | ||
let sandbox; | ||
|
||
setup(() => { | ||
sandbox = sinon.createSandbox(); | ||
|
||
sandbox.stub(cypressScaffolder, 'scaffold'); | ||
sandbox.stub(vulnerableScaffolder, 'scaffold'); | ||
}); | ||
|
||
teardown(() => sandbox.restore()); | ||
|
||
test('that cypress is configured for smoke testing', async () => { | ||
const projectRoot = any.string(); | ||
const cypressResults = any.simpleObject(); | ||
const vulnerableResults = any.simpleObject(); | ||
const baseUrl = 'http://localhost:8000'; | ||
cypressScaffolder.scaffold | ||
.withArgs({projectRoot, testDirectory: 'test/smoke/', testBaseUrl: baseUrl}) | ||
.resolves(cypressResults); | ||
vulnerableScaffolder.scaffold.withArgs({baseUrl}).resolves(vulnerableResults); | ||
|
||
assert.deepEqual( | ||
await scaffoldTesting({projectRoot}), | ||
deepmerge.all([ | ||
cypressResults, | ||
vulnerableResults, | ||
{ | ||
scripts: { | ||
'test:served': "start-server-and-test 'npm start' http://localhost:8000" | ||
+ " 'npm-run-all --print-label --parallel test:served:*'", | ||
'test:served:smoke': 'run-s cypress:run' | ||
}, | ||
devDependencies: ['start-server-and-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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import deepmerge from 'deepmerge'; | ||
import {scaffold as scaffoldCypress} from '@form8ion/cypress-scaffolder'; | ||
import {scaffold as scaffoldVulnerable} from '@form8ion/is-website-vulnerable'; | ||
|
||
export default async function ({projectRoot}) { | ||
const devServerUrl = 'http://localhost:8000'; | ||
|
||
const [cypressResults, vulnerableResults] = await Promise.all([ | ||
scaffoldCypress({projectRoot, testDirectory: 'test/smoke/', testBaseUrl: devServerUrl}), | ||
scaffoldVulnerable({baseUrl: devServerUrl}) | ||
]); | ||
|
||
return deepmerge.all([ | ||
cypressResults, | ||
vulnerableResults, | ||
{ | ||
scripts: { | ||
'test:served': 'start-server-and-test ' | ||
+ `'npm start' ${devServerUrl} 'npm-run-all --print-label --parallel test:served:*'`, | ||
'test:served:smoke': 'run-s cypress:run' | ||
}, | ||
devDependencies: ['start-server-and-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
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,7 +1,9 @@ | ||
import {promises as fs} from 'fs'; | ||
import {resolve} from 'path'; | ||
import {After, When} from '@cucumber/cucumber'; | ||
import stubbedFs from 'mock-fs'; | ||
|
||
const packagePreviewDirectory = '../__package_previews__/slidev'; | ||
const stubbedNodeModules = stubbedFs.load(resolve(__dirname, '..', '..', '..', '..', 'node_modules')); | ||
|
||
After(function () { | ||
|
@@ -13,8 +15,33 @@ When('the project is scaffolded', async function () { | |
const {scaffold} = require('@form8ion/slidev'); | ||
|
||
stubbedFs({ | ||
node_modules: stubbedNodeModules | ||
node_modules: stubbedNodeModules, | ||
[packagePreviewDirectory]: { | ||
'@form8ion': { | ||
slidev: { | ||
node_modules: { | ||
'.pnpm': { | ||
'@[email protected]': { | ||
node_modules: { | ||
'@form8ion': { | ||
'cypress-scaffolder': { | ||
templates: { | ||
'canary-spec.js': await fs.readFile(resolve( | ||
__dirname, | ||
'../../../../', | ||
'node_modules/@form8ion/cypress-scaffolder/templates/canary-spec.js' | ||
)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
|
||
await scaffold({projectRoot: process.cwd()}); | ||
this.results = await scaffold({projectRoot: process.cwd()}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
test/integration/features/step_definitions/scaffold-steps.js
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,44 @@ | ||
import {promises as fs} from 'fs'; | ||
import {Then} from '@cucumber/cucumber'; | ||
import {assert} from 'chai'; | ||
|
||
Then('the expected files are generated', async function () { | ||
assert.equal( | ||
await fs.readFile(`${process.cwd()}/slides.md`, 'utf-8'), | ||
`--- | ||
theme: default | ||
# random image from a curated Unsplash collection by Anthony | ||
# like them? see https://unsplash.com/collections/94734566/slidev | ||
background: https://source.unsplash.com/collection/94734566/1920x1080 | ||
# apply any windi css classes to the current slide | ||
class: 'text-center' | ||
# https://sli.dev/custom/highlighters.html | ||
highlighter: prism | ||
# some information about the slides, markdown enabled | ||
info: | | ||
## Slidev Starter Template | ||
Presentation slides for developers. | ||
Learn more at [Sli.dev](https://sli.dev) | ||
---` | ||
); | ||
}); | ||
|
||
Then('the scripts are defined', async function () { | ||
assert.include( | ||
this.results.scripts, | ||
{ | ||
dev: 'slidev', | ||
build: 'slidev build', | ||
export: 'slidev export' | ||
} | ||
); | ||
}); | ||
|
||
Then('the framework dependencies are installed', async function () { | ||
assert.deepEqual(this.results.dependencies, ['@slidev/cli', '@slidev/theme-default']); | ||
}); |
Oops, something went wrong.