Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

buchu

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buchu - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

7

package.json
{
"name": "buchu",
"version": "1.0.3",
"version": "1.0.4",
"description": "Uniform, auditable and secure use case javascript library. Influenced by Clean Architecture and Trailblazer",

@@ -13,6 +13,6 @@ "main": "./src/buchu.js",

"type": "git",
"url": "https://github.com/dalssoft/buchu.git"
"url": "https://github.com/herbsjs/buchu.git"
},
"bugs": {
"url": "https://github.com/dalssoft/buchu/issues/"
"url": "https://github.com/herbsjs/buchu/issues/"
},

@@ -28,2 +28,3 @@ "engines": {

"author": "David Lojudice Sb",
"homepage": "https://github.com/herbsjs/buchu#readme",
"license": "MIT",

@@ -30,0 +31,0 @@ "dependencies": {

class Ok {
constructor(value) {
this.value = value;
this.value = value
if (value instanceof Ok)
this.value = value.value
}

@@ -23,3 +25,5 @@

constructor(error) {
this._error = error;
this._error = error
if (error instanceof Err)
this._error = error._error
}

@@ -26,0 +30,0 @@

@@ -59,3 +59,7 @@ const { Ok, Err } = require('./results')

}
return Ok({ ...this.context.ret })
const ret = this.context.ret
if (ret.__proto__ === Ok().__proto__)
return Ok(ret)
else
return Ok({ ...ret })
}

@@ -62,0 +66,0 @@

@@ -167,2 +167,88 @@ const { usecase } = require('../../src/usecase')

describe('the simplest use case with context returning multiple Oks or Errs', () => {
context('returning Ok', () => {
const givenAnUseCaseWithOkReturn = () => {
const uc = usecase('A use case', {
'Change return': step({
'step r1': step((ctx) => { ctx.ret = Ok('uc ret'); return Ok('step1 ret') }),
})
})
return uc
}
it('should run', async () => {
//given
const uc = givenAnUseCaseWithOkReturn()
//when
const ret = await uc.run()
//then
assert.ok(ret.isOk)
assert.deepEqual(ret.value, 'uc ret')
})
it('should audit', async () => {
//given
const uc = givenAnUseCaseWithOkReturn()
//when
await uc.run()
//then
assert.deepEqual(uc.auditTrail, {
type: 'use case',
description: 'A use case',
transactionId: uc._mainStep._auditTrail.transactionId,
return: Ok('uc ret'), steps: [
{
type: 'step', description: 'Change return', return: Ok('uc ret'), steps: [
{ type: 'step', description: 'step r1', return: Ok('step1 ret') },
]
}]
})
})
})
context('returning Err', () => {
const givenAnUseCaseWithErrReturn = () => {
const uc = usecase('A use case', {
'Change return': step({
'step r1': step((ctx) => { ctx.ret = Err('uc ret'); return Err('step1 ret') }),
})
})
return uc
}
it('should run', async () => {
//given
const uc = givenAnUseCaseWithErrReturn()
//when
const ret = await uc.run()
//then
assert.ok(ret.isErr)
assert.deepEqual(ret.err, 'step1 ret')
})
it('should audit', async () => {
//given
const uc = givenAnUseCaseWithErrReturn()
//when
await uc.run()
//then
assert.deepEqual(uc.auditTrail, {
type: 'use case',
description: 'A use case',
transactionId: uc._mainStep._auditTrail.transactionId,
return: Err('step1 ret'), steps: [
{
type: 'step', description: 'Change return', return: Err('step1 ret'), steps: [
{ type: 'step', description: 'step r1', return: Err('step1 ret') },
]
}]
})
})
})
})
describe('the simplest use case with request', () => {

@@ -221,3 +307,3 @@

},
type: "use case",
type: "use case",
description: "A use case",

@@ -224,0 +310,0 @@ steps: [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc