| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 'use strict';
- const { expect } = require('chai');
- const { sequelize, Ven } = require('../../../db');
- const { v4 } = require('uuid');
- describe('VEN Model', function() {
- before(async () => {
- await sequelize.sync();
- });
-
- describe('Retrieval', function() {
- it('returns no results for unknown ven_id', async () => {
- const randomVenId = v4();
- const existing = await Ven.findOne({ where: { ven_id: randomVenId } });
- expect(existing).to.be.null;
- });
- it('retrieves a saved record when queried by ven_id', async () => {
- const randomVenId = v4();
- const randomCommonName = v4();
- const ven = new Ven();
- ven.ven_id = randomVenId;
- ven.common_name = randomCommonName;
- await ven.save();
- const existing = await Ven.findOne({ where: { ven_id: randomVenId } });
- expect(existing).to.not.be.undefined;
- expect(existing.common_name).to.eql(randomCommonName);
- });
- it('retrieves a saved record when queried by common_name', async () => {
- const randomVenId = v4();
- const randomCommonName = v4();
- const ven = new Ven();
- ven.ven_id = randomVenId;
- ven.common_name = randomCommonName;
- await ven.save();
- const existing = await Ven.findOne({ where: { common_name: randomCommonName } });
- expect(existing).to.not.be.undefined;
- expect(existing.common_name).to.eql(randomCommonName);
- });
- });
- });
|