vendredi 16 octobre 2020

How to test a if condition block of code.?

I am new developer learning unit testing , I have find a code in my project which need to be unit test and i am stuck. Any help appreciated.

let oldConfigForLogs = null;
const logConfigIfChanged = () => {
  if (Config && Config.current) {
    if (
      oldConfigForLogs === null ||
      JSON.stringify(oldConfigForLogs) !== JSON.stringify(Config.current)
    ) {
      logger.info(
        `Updated feature flag config: ${JSON.stringify(Config.current)}`
      );
    }
    oldConfigForLogs = Config.current;
  }
};

Aucun commentaire:

Enregistrer un commentaire