"use strict";

var _tape = _interopRequireDefault(require("tape"));

var _localAnestheticsList = require("./local-anesthetics-list");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(0, _tape.default)('generates full list of local anesthetic names', t => {
  const expectedList = ['2% Lidocaine (no epi)', '2% Lidocaine 1:50,000 epi', '2% Lidocaine 1:100,000 epi', '4% Articaine 1:100,000 epi', '4% Articaine 1:200,000 epi', '0.5% Bupivacaine 1:200,000 epi', '4% Prilocaine 1:200,000 epi', '4% Prilocaine (no epi)', '3% Mepivacaine', '2% Mepivacaine 1:20,000 Levonordefrin', '1.33% Exparel™', '0.02% OraVerse™ 0.4 mg/1.7 mL'];
  t.deepEqual(_localAnestheticsList.localAnestheticVariantsList.map(_localAnestheticsList.getLocalVariantLabel), expectedList);
  const expectedKeysTypes = {
    percent: 'number',
    epi: 'number',
    name: 'string',
    id: 'string',
    input: 'string',
    rxcui: 'string',
    // we make an exception for a single drug down below
    halfLife: 'number',
    color: 'string'
  };
  const optionalFields = {
    subName: 'string',
    brandName: 'string',
    altName: 'string',
    nameForChart: 'string',
    aapdAbsoluteMax: 'number',
    aapdRatioMax: 'number',
    manRatioMax: 'number',
    manAbsoluteMax: 'number',
    minAge: 'number',
    drugIdOverride: 'string',
    unitForChart: 'string',
    enableDilute: 'boolean',
    reminder: 'string',
    noEpiWarning: 'string',
    ageWarning: 'string',
    skipForToxicity: 'boolean'
  };
  const allKeys = [...Object.keys(expectedKeysTypes), ...Object.keys(optionalFields)];
  t.ok(_localAnestheticsList.localAnestheticVariantsList.every(variant => {
    for (const key in variant) {
      if (!allKeys.includes(key)) {
        throw Error("".concat(variant.name, " got unexpected key ").concat(key));
      }
    }

    for (const key in expectedKeysTypes) {
      if (typeof variant[key] !== expectedKeysTypes[key]) {
        if (variant.skipForToxicity && key === 'halfLife') {
          continue;
        }

        throw Error("".concat(variant.name, " ").concat(key, " should be ").concat(expectedKeysTypes[key]));
      }
    }

    return true;
  }));
  t.end();
});