Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <[email protected]>
  • Loading branch information
mcollina committed Apr 19, 2024
1 parent ef5b609 commit 1102934
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion asyncforge.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { AsyncLocalStorage } = require('node:async_hooks')

const asyncLocalStorage = new AsyncLocalStorage();
const asyncLocalStorage = new AsyncLocalStorage()

function start (config) {
const store = Object.create(null)
Expand Down
20 changes: 20 additions & 0 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const tspl = require('@matteo.collina/tspl')
test('start and forge', async (t) => {
const { a, b } = require('./fixture/basic')

start({
foo: 'bar'
})

assert.deepEqual(a(), { value: 'bar' })
assert.equal(a(), a())
assert.deepEqual(b(), {
Expand All @@ -20,6 +24,22 @@ test('start and forge', async (t) => {
await immediate()

assert.deepEqual(a(), { value: 'bar' })

start({
foo: 'baz'
})

assert.deepEqual(a(), { value: 'baz' })
assert.equal(a(), a())
assert.deepEqual(b(), {
fromA: {
value: 'baz'
}
})

await immediate()

assert.deepEqual(a(), { value: 'baz' })
})

test('start and forge with different config', async (t) => {
Expand Down
6 changes: 0 additions & 6 deletions test/fixture/basic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
const a = require('./a')
const b = require('./b')

const { start } = require('../../../')

start({
foo: 'bar'
})

module.exports = {
a,
b
Expand Down
4 changes: 1 addition & 3 deletions test/memo.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict'

const { test } = require('node:test')
const assert = require('node:assert/strict')
const { start, forge, memo } = require('../')
const { setImmediate: immediate } = require('node:timers/promises')
const { start, memo } = require('../')
const tspl = require('@matteo.collina/tspl')

test('memo', async (t) => {
Expand Down

0 comments on commit 1102934

Please sign in to comment.