Skip to content

Commit

Permalink
test: fully use jest
Browse files Browse the repository at this point in the history
remove the assert and sinon usages
  • Loading branch information
nfroidure committed Nov 19, 2024
1 parent fd51f27 commit e2643a2
Show file tree
Hide file tree
Showing 11 changed files with 638 additions and 632 deletions.
15 changes: 13 additions & 2 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<dt><a href="#initInitializerBuilder">initInitializerBuilder(services)</a> ⇒ <code>Promise.&lt;function()&gt;</code></dt>
<dd><p>Instantiate the initializer builder service</p>
</dd>
<dt><a href="#initDispose">initDispose()</a></dt>
<dd><p>Allow to dispose the services of an
initialized silo content.</p>
</dd>
<dt><a href="#constant">constant(name, value)</a> ⇒ <code>function</code></dt>
<dd><p>Decorator that creates an initializer for a constant value</p>
</dd>
Expand Down Expand Up @@ -212,6 +216,13 @@ const buildInitializer = await initInitializerBuilder({

const content = await buildInitializer(['entryPoint']);
```
<a name="initDispose"></a>

## initDispose()
Allow to dispose the services of an
initialized silo content.

**Kind**: global function
<a name="constant"></a>

## constant(name, value) ⇒ <code>function</code>
Expand Down Expand Up @@ -255,7 +266,7 @@ Decorator that creates an initializer from a service builder
| [name] | <code>String</code> | The service's name |
| [dependencies] | <code>Array.&lt;String&gt;</code> | The service's injected dependencies |
| [singleton] | <code>Boolean</code> | Whether the service is a singleton or not |
| [extra] | <code>any</code> | Eventual extra informations |
| [extra] | <code>any</code> | Eventual extra information |

**Example**
```js
Expand Down Expand Up @@ -303,7 +314,7 @@ Decorator that creates an initializer for a provider
| [name] | <code>String</code> | The service's name |
| [dependencies] | <code>Array.&lt;String&gt;</code> | The service's dependencies |
| [singleton] | <code>Boolean</code> | Whether the service is a singleton or not |
| [extra] | <code>any</code> | Eventual extra informations |
| [extra] | <code>any</code> | Eventual extra information |

**Example**
```js
Expand Down
6 changes: 3 additions & 3 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ A service provider is full of state since its concern is
referred to as another initializer dependency.
- type: an initializer can be of three types at the moment
(constant, service or provider). The initializer annotations
varies accordsing to those types as we'll see later on.
varies according to those types as we'll see later on.
- injected dependencies: an array of dependencies declarations that
declares which initializer htis initializer depends on. Constants
declares which initializer this initializer depends on. Constants
logically cannot have dependencies.
- options: various options like for exemple, if the initializer
- options: various options like for example, if the initializer
implements the singleton pattern or not.
- value: only used for constant, this property allows to know
the value the initializer resolves to without actually executing it.
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@ is maybe the best feature of this library 😉.
<dt><a href="#initInitializerBuilder">initInitializerBuilder(services)</a> ⇒ <code>Promise.&lt;function()&gt;</code></dt>
<dd><p>Instantiate the initializer builder service</p>
</dd>
<dt><a href="#initDispose">initDispose()</a></dt>
<dd><p>Allow to dispose the services of an
initialized silo content.</p>
</dd>
<dt><a href="#constant">constant(name, value)</a> ⇒ <code>function</code></dt>
<dd><p>Decorator that creates an initializer for a constant value</p>
</dd>
Expand Down Expand Up @@ -634,6 +638,13 @@ const buildInitializer = await initInitializerBuilder({

const content = await buildInitializer(['entryPoint']);
```
<a name="initDispose"></a>

## initDispose()
Allow to dispose the services of an
initialized silo content.

**Kind**: global function
<a name="constant"></a>

## constant(name, value) ⇒ <code>function</code>
Expand Down Expand Up @@ -677,7 +688,7 @@ Decorator that creates an initializer from a service builder
| [name] | <code>String</code> | The service's name |
| [dependencies] | <code>Array.&lt;String&gt;</code> | The service's injected dependencies |
| [singleton] | <code>Boolean</code> | Whether the service is a singleton or not |
| [extra] | <code>any</code> | Eventual extra informations |
| [extra] | <code>any</code> | Eventual extra information |

**Example**
```js
Expand Down Expand Up @@ -725,7 +736,7 @@ Decorator that creates an initializer for a provider
| [name] | <code>String</code> | The service's name |
| [dependencies] | <code>Array.&lt;String&gt;</code> | The service's dependencies |
| [singleton] | <code>Boolean</code> | Whether the service is a singleton or not |
| [extra] | <code>any</code> | Eventual extra informations |
| [extra] | <code>any</code> | Eventual extra information |

**Example**
```js
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
"metapak-nfroidure": "^18.2.0",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"sinon": "^14.0.0",
"typescript": "^5.5.3",
"typescript-eslint": "^7.16.0"
},
Expand Down
4 changes: 4 additions & 0 deletions src/dispose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const debug = initDebug('knifecycle');

export const DISPOSE = '$dispose';

/**
* Allow to dispose the services of an
* initialized silo content.
*/
async function initDispose({
$instance,
$siloContext,
Expand Down
4 changes: 4 additions & 0 deletions src/fatalError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const debug = initDebug('knifecycle');

export const FATAL_ERROR = '$fatalError';

/**
* Allow to manage processes lifecycle fatal
* errors.
*/
export type FatalErrorService = {
errorPromise: Promise<void>;
registerErrorPromise: (errorPromise: Promise<void>) => void;
Expand Down
Loading

0 comments on commit e2643a2

Please sign in to comment.