Skip to content

Commit

Permalink
Add test for configuration items
Browse files Browse the repository at this point in the history
Also, added cleanup after each test.
  • Loading branch information
aedart committed Oct 3, 2024
1 parent 7ef6b0a commit d324c2e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/browser/packages/core/application/configure.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CORE } from "@aedart/contracts/core";
import { CONTAINER } from "@aedart/contracts/container";
import { Config } from "@aedart/support/facades";
import {
Application,
BaseConfigurator,
Expand All @@ -26,6 +27,8 @@ describe('@aedart/core', () => {
expect(callback)
.withContext('Should NOT accept invalid configurator instance')
.toThrowError(ConfigurationError);

app.destroy();
});

it('can be configured using configurator instance', () => {
Expand All @@ -50,6 +53,8 @@ describe('@aedart/core', () => {
expect(invoked)
.withContext('Configurator (instance) not applied')
.toBeTrue();

app.destroy();
});

it('can be configured using configurator class constructor', () => {
Expand All @@ -74,6 +79,8 @@ describe('@aedart/core', () => {
expect(invoked)
.withContext('Configurator (constructor) not applied')
.toBeTrue();

app.destroy();
});

it('can be configured using configurator callback', () => {
Expand All @@ -93,6 +100,8 @@ describe('@aedart/core', () => {
expect(invoked)
.withContext('Configurator (callback) not applied')
.toBeTrue();

app.destroy();
});

it('applies a default application configurator', () => {
Expand Down Expand Up @@ -122,6 +131,37 @@ describe('@aedart/core', () => {
expect(app.coreBootstrappers.length)
.withContext('No core bootstrappers have been registered')
.toBeGreaterThan(0);

app.destroy();
});

it('configuration items are set', () => {

const items = {
app: {
name: 'Core Application'
}
}

const app = new Application();

// ---------------------------------------------------------------------------- //

app
.configure( (configurator) => configurator.with(items) )
.run();

// ---------------------------------------------------------------------------- //

const result = Config
.obtain()
.get('app.name');

expect(result)
.withContext('Configuration items do not appear to have been set')
.toBe(items.app.name);

app.destroy();
});
});
});

0 comments on commit d324c2e

Please sign in to comment.