mardi 18 décembre 2018

Passing a test Mocha chai

Hey guys Im trying to pass this test but the result is coming out undefined im not sure why ? is due to async ?

const Immutable = require("immutable");
const assert = require("chai").assert;

newError = error => {
  error
    .map(value => {
      return value.map(v => `${v}.`).join(" ");
    })
    .toJS();
};

it("should tranform errors", () => {
  let error = Immutable.Map({
    name: ["This field is required", "Another error"],
    age: ["Only numeric characters are allowed"]
  });

  let result = newError(error);

  assert.deepEqual(result, {
    name: "This field is required. Another error.",
    age: "Only numeric characters are allowed."
  });

});

Aucun commentaire:

Enregistrer un commentaire