Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit 5eccf3e

Browse files
authored
fix: Allows persona creation without name (LLC-57) (#305)
1 parent 2d64b61 commit 5eccf3e

3 files changed

Lines changed: 2 additions & 29 deletions

File tree

src/mongoModelsRepo/createPersona.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@ import { PERSONAS_COLLECTION } from './utils/constants/collections';
88
export default (config: Config) => {
99
return async (opts: CreatePersonaOptions): Promise<CreatePersonaResult> => {
1010
const collection = (await config.db).collection(PERSONAS_COLLECTION);
11-
const personaId = new ObjectID();
1211

1312
// Docs: http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#insertOne
1413
// Docs: http://bit.ly/insertOneWriteOpResult
1514
const opResult = await collection.insertOne({
16-
_id: personaId,
17-
name: Boolean(opts.name) ? opts.name : personaId.toString(),
15+
name: opts.name,
1816
organisation: new ObjectID(opts.organisation),
1917
}, {});
2018

2119
// Formats the persona to be returned.
2220
const persona: Persona = {
2321
id: opResult.insertedId.toString(),
24-
name: Boolean(opts.name) ? opts.name : personaId.toString(),
22+
name: opts.name,
2523
organisation: opts.organisation,
2624
};
2725

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import * as assert from 'assert';
22
import createTestPersona from '../utils/createTestPersona';
3-
import createTestPersonaWithoutName from '../utils/createTestPersonaWithoutName';
43
import setup from '../utils/setup';
54
import { TEST_ORGANISATION } from '../utils/values';
65

76
describe('createPersona', () => {
8-
97
const service = setup();
108

119
it('Should create persona', async () => {
@@ -19,16 +17,4 @@ describe('createPersona', () => {
1917
assert.equal(actualPersona.name, 'Dave');
2018
assert.equal(actualPersona.organisation, TEST_ORGANISATION);
2119
});
22-
23-
it('Should create a persona with personaId instead name, if name not exists.', async () => {
24-
const persona = await createTestPersonaWithoutName();
25-
const {persona: actualPersona} = await service.getPersona({
26-
organisation: TEST_ORGANISATION,
27-
personaId: persona.id,
28-
});
29-
30-
assert.equal(actualPersona.id, persona.id);
31-
assert.equal(actualPersona.name, persona.id.toString());
32-
assert.equal(actualPersona.organisation, TEST_ORGANISATION);
33-
});
3420
});

src/tests/utils/createTestPersonaWithoutName.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)