Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add tests to sample applications. (#927)
* feat: Add tests to sample applications. * 4.0.0-internal.17 * Put internal publish command to README.md. * Export ApplicationDefinition type. * 4.0.0-internal.18 * Add tests for chat sample. * Add missing validation checks. * 4.0.0-internal.19 * Add more tests. * 4.0.0-internal.20 * Add missing tests. * 4.0.0-internal.21 * Add application tests.
- Loading branch information
Showing
29 changed files
with
715 additions
and
17 deletions.
There are no files selected for viewing
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
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
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
34 changes: 34 additions & 0 deletions
34
templates/blank/javascript/test/domain/sampleContext/sampleAggregateTests.js
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,34 @@ | ||
'use strict'; | ||
|
||
const { assert } = require('assertthat'); | ||
const path = require('path'); | ||
const { uuid } = require('uuidv4'); | ||
const { getApplicationDefinition, sandbox } = require('wolkenkit'); | ||
|
||
suite('sampleAggregate', () => { | ||
let applicationDefinition; | ||
|
||
suiteSetup(async () => { | ||
applicationDefinition = await getApplicationDefinition({ | ||
applicationDirectory: path.join(__dirname, '..', '..', '..') | ||
}); | ||
}); | ||
|
||
suite('sampleCommand', () => { | ||
test('publishes a sample domain event.', async () => { | ||
const contextIdentifier = { name: 'sampleContext' }; | ||
const aggregateIdentifier = { name: 'sampleAggregate', id: uuid() }; | ||
|
||
await sandbox(). | ||
withApplicationDefinition({ applicationDefinition }). | ||
forAggregate({ contextIdentifier, aggregateIdentifier }). | ||
when({ name: 'sampleCommand', data: {}}). | ||
then(({ domainEvents, state }) => { | ||
assert.that(domainEvents.length).is.equalTo(1); | ||
assert.that(domainEvents[0].name).is.equalTo('sampleDomainEvent'); | ||
assert.that(domainEvents[0].data).is.equalTo({}); | ||
assert.that(state).is.equalTo({ domainEventNames: [ 'sampleDomainEvent' ]}); | ||
}); | ||
}); | ||
}); | ||
}); |
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
33 changes: 33 additions & 0 deletions
33
templates/blank/typescript/test/domain/sampleContext/sampleAggregateTests.ts
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,33 @@ | ||
import { assert } from 'assertthat'; | ||
import path from 'path'; | ||
import { SampleCommandData } from '../../../server/domain/sampleContext/sampleAggregate/commands/sampleCommand'; | ||
import { uuid } from 'uuidv4'; | ||
import { ApplicationDefinition, getApplicationDefinition, sandbox } from 'wolkenkit'; | ||
|
||
suite('sampleAggregate', (): void => { | ||
let applicationDefinition: ApplicationDefinition; | ||
|
||
suiteSetup(async (): Promise<void> => { | ||
applicationDefinition = await getApplicationDefinition({ | ||
applicationDirectory: path.join(__dirname, '..', '..', '..') | ||
}); | ||
}); | ||
|
||
suite('sampleCommand', (): void => { | ||
test('publishes a sample domain event.', async (): Promise<void> => { | ||
const contextIdentifier = { name: 'sampleContext' }; | ||
const aggregateIdentifier = { name: 'sampleAggregate', id: uuid() }; | ||
|
||
await sandbox(). | ||
withApplicationDefinition({ applicationDefinition }). | ||
forAggregate({ contextIdentifier, aggregateIdentifier }). | ||
when<SampleCommandData>({ name: 'sampleCommand', data: {}}). | ||
then(({ domainEvents, state }): void => { | ||
assert.that(domainEvents.length).is.equalTo(1); | ||
assert.that(domainEvents[0].name).is.equalTo('sampleDomainEvent'); | ||
assert.that(domainEvents[0].data).is.equalTo({}); | ||
assert.that(state).is.equalTo({ domainEventNames: [ 'sampleDomainEvent' ]}); | ||
}); | ||
}); | ||
}); | ||
}); |
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,5 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"rootDir": ".", | ||
"sourceMap": true | ||
}, | ||
|
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
Oops, something went wrong.