-
-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
describe('TODOItems Specification', () => {
let postgres: StartedPostgreSqlContainer;
let connectionString: string
let given: PostgreSQLProjectionSpec<TODOItemMarkedCompleted | TODOItemCreated | TODOItemDeleted>
before(async () => {
postgres = await new PostgreSqlContainer("postgres").start();
connectionString = postgres.getConnectionUri();
given = PostgreSQLProjectionSpec.for({
projection: TODOItemsProjection,
connectionString,
});
});
it('spec: TODO Items', async () => {
const createdAt = new Date()
const itemId = "2"
const name = "test-name"
await given([{
type: 'TODOItemCreated',
data: {
itemId: itemId,
name: name,
createdAt:createdAt
},
metadata: {streamName: 'd295d10a-a123-48a3-b3ae-41e934ced794'}
}])
.when([])
.then(
expectPongoDocuments
.fromCollection<TODOItemsReadModel>(
"TODOItems-collection",
)
.withId("d295d10a-a123-48a3-b3ae-41e934ced794")
.toBeEqual({
data: [{
itemId: itemId,
name: name,
}]
}),
);
});
});
This test case fails
Error: subObj:
{"data":[{"itemId":"2","name":"test-name"}]}
is not equal to
{"data":[{"name":"test-name","itemId":"2"}]}
It is green if itemId is "foo"
at assertDeepEqual (/private/tmp/foo2/TODO/node_modules/@event-driven-io/emmett/src/testing/assertions.ts:138:5)
at assertDocumentsEqual (/private/tmp/foo2/TODO/node_modules/@event-driven-io/emmett-postgresql/src/eventStore/projections/pongo/pongoProjectionSpec.ts:67:3)
at withCollection (/private/tmp/foo2/TODO/node_modules/@event-driven-io/emmett-postgresql/src/eventStore/projections/pongo/pongoProjectionSpec.ts:95:9)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at executeInNewConnection (/private/tmp/foo2/TODO/node_modules/@event-driven-io/dumbo/src/core/execute/execute.ts:151:12)
at Object.then (/private/tmp/foo2/TODO/node_modules/@event-driven-io/emmett-postgresql/src/eventStore/projections/postgresProjectionSpec.ts:126:19)
at TestContext.<anonymous> (/private/tmp/foo2/TODO/src/app/slices/TODOItems/TODOItemsProjection.test.ts:30:9)
at async Test.run (node:internal/test_runner/test:748:9)
at async Promise.all (index 0)
at async Suite.run (node:internal/test_runner/test:1106:7)
Metadata
Metadata
Assignees
Labels
No labels