-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): test command: now it is possible to run herbs tests and s…
…pecs (aloe)
- Loading branch information
Showing
12 changed files
with
198 additions
and
18 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 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,11 +1,10 @@ | ||
|
||
const command = { | ||
name: 'herbs', | ||
run: async toolbox => { | ||
const { print } = toolbox | ||
|
||
print.info('Welcome to your Herbs CLI') | ||
toolbox.print.info("Welcome to Herbs CLI 🌿") | ||
toolbox.print.info("Type 'herbs help' for more information") | ||
} | ||
|
||
} | ||
|
||
module.exports = command |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const glob = require('glob') | ||
const path = require('path') | ||
|
||
const cmd = { | ||
name: 'test', | ||
description: 'Run Herbs spec tests', | ||
alias: ['t'], | ||
run: async toolbox => { | ||
|
||
const files = glob.sync('./**/*.aloe.test.js') | ||
for (const file of files) { | ||
const instance = require(path.resolve(file)) | ||
if (instance.isSpec) { | ||
const ret = await instance.run() | ||
console.log(ret, instance) | ||
} | ||
} | ||
toolbox.print.success('Test finished! 🤩') | ||
} | ||
} | ||
|
||
|
||
|
||
module.exports = cmd |
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
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,49 @@ | ||
const create<%- props.name.pascalCase %> = require('./create<%- props.name.pascalCase %>') | ||
const assert = require('assert') | ||
const { spec, scenario, given, check } = require('@herbsjs/aloe') | ||
const { herbarium } = require('@herbsjs/herbarium') | ||
|
||
const create<%- props.name.pascalCase %>Spec = spec({ | ||
usecase: create<%- props.name.pascalCase %>, | ||
'Create a new <%- props.name.raw %> when it is valid': scenario({ | ||
'Given a simple <%- props.name.raw %> is valid': given({ | ||
request: { | ||
<%- props.request.valid %> | ||
}, | ||
user: { hasAccess: true }, | ||
injection: { | ||
<%- props.name.camelCase %>Repository: new ( class <%- props.name.pascalCase %>Repository { | ||
async insert(<%- props.name.camelCase %>) { return (<%- props.name.camelCase %>) } | ||
}) | ||
}, | ||
}), | ||
|
||
// when: default when for use case | ||
|
||
'Must return Ok': check((ctx) => { | ||
assert.ok(ctx.response.isOk) | ||
}), | ||
|
||
'Must return a valid <%- props.name.raw %>': check((ctx) => { | ||
assert.strictEqual(ctx.response.ok.isValid(), true) | ||
// TODO: check if it is really a <%- props.name.raw %> | ||
}) | ||
|
||
}), | ||
|
||
// 'Do not create a new <%- props.name.raw %> when it is invalid': scenario({}) | ||
// const injection = {} | ||
// const req = { | ||
// <%- props.request.invalid %> | ||
// } | ||
// assert.ok(ret.isErr) | ||
// assert.ok(ret.isInvalidEntityError) | ||
}) | ||
|
||
module.exports = create<%- props.name.pascalCase %>Spec | ||
|
||
//module.exports = | ||
// herbarium.specs | ||
// .add(create<%- props.name.pascalCase %>Spec, 'Create<%- props.name.pascalCase %>Spec') | ||
// .metadata({ usecase: 'Create<%- props.name.pascalCase %>' }) | ||
// .usecase |
Empty file.
Empty file.
Empty file.
Empty file.