<commit_before>const should = require('should');
const mongoose = require('mongoose');
const async= require('async');

const clearDatabase = require('../utils/clear-database');
const haar = require('../../index');
const DeviceTypeModel = require('../../lib/models/device-type');

describe('Device type model', function() {

  before(function (done) {
    haar.init();

    clearDatabase(function () {
      done();
    });
  });

  after(function (done) {
    mongoose.disconnect();
    return done();
  });

  describe('#create', function() {
    it('should create a new device type', function(done) {
      DeviceTypeModel.create({
        name: '<NAME>',
        description: 'A test sensor',
        developer: '<NAME>',
        deviceClass: 'input',
        dataDescriptor: [
          {
            label: 'Time',
            unit: {<commit_msg>device-type: test coverage for unique data descriptors<commit_after>const should = require('should');
const mongoose = require('mongoose');
const async= require('async');

const clearDatabase = require('../utils/clear-database');
const haar = require('../../index');
const DeviceTypeModel = require('../../lib/models/device-type');

describe('Device type model', function() {

  before(function (done) {
    haar.init();

    clearDatabase(function () {
      done();
    });
  });

  after(function (done) {
    mongoose.disconnect();
    return done();
  });

  describe('#create', function() {
    it('should enforce unique data descriptors', function(done) {
      DeviceTypeModel.create({
        name: 'Test Sensor',
        description: 'A test sensor',
        developer: '<NAME>',
        deviceClass: 'input',
        dataDescriptor: [
          {
            label: 'Time',
            name: 'time',
            unit: {
              longform: 'Seconds',
              shortform: 's',
            },
            max: 60,
            min: 0,
          },
          {
            label: 'Fail Time',
            name: 'time',
            unit: {
              longform: 'Seconds',
              shortform: 's',
            },
            max: 60,
            min: 0,
          },
        ]
      }, function (err, deviceType) {
        should(err).not.be.null();
        done();
      });
    });

    it('should create a new device type', function(done) {
      DeviceTypeModel.create({
        name: 'Test Sensor',
        description: 'A test sensor',
        developer: 'Haar Engine',
        deviceClass: 'input',
        dataDescriptor: [
          {
            label: 'Time',
            name: 'time',
            unit: {
{'fraction_non_alphanumeric': 0.15681730397837002, 'fraction_numerical': 0.002317497103128621, 'mean_word_length': 1.9804372842347526, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6582709', 'n_tokens_mistral': 707, 'n_tokens_neox': 700, 'n_words': 173}