diff --git a/modules/entry/back/models/specs/entry-observation.spec.js b/modules/entry/back/models/specs/entry-observation.spec.js new file mode 100644 index 0000000000..fca13139c4 --- /dev/null +++ b/modules/entry/back/models/specs/entry-observation.spec.js @@ -0,0 +1,29 @@ +const app = require('vn-loopback/server/server'); + +describe('EntryObservation', () => { + const entryId = 1; + + it('should throw a user error if the observation type is duplicated.', async() => { + const observations = [ + { + entryFk: entryId, + observationTypeFk: 1, + description: 'repeated description' + }, + { + entryFk: entryId, + observationTypeFk: 1, + description: 'repeated description' + }, + ]; + + let error; + try { + await app.models.EntryObservation.create(observations); + } catch (e) { + error = e; + } + + expect(error).toBeDefined(); + }); +});