Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
#21 - Unit test checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Wright, Christopher R <Christopher.Wright@ca.com>
  • Loading branch information
Wright, Christopher R authored and Wright, Christopher R committed Sep 18, 2018
1 parent e2d4236 commit f3b045d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions packages/settings/__tests__/AppSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { existsSync } from "fs";
import { SettingsAlreadyInitialized, SettingsNotInitialized } from "../src/errors";
import { readFileSync, writeFileSync } from "jsonfile";
import { ISettingsFile } from "../src/doc/ISettingsFile";
import over = require("lodash/fp/over");

fdescribe("AppSettings", () => {
const mocks = {
Expand Down Expand Up @@ -110,15 +109,30 @@ fdescribe("AppSettings", () => {
const recoveryFcn = jest.fn((arg1, arg2) => {
expect(arg1).toEqual(fileName);
expect(arg2).toEqual(defaultSettings);
console.log("passed here");

return overwriteSettings;
});

AppSettings.initialize(fileName, recoveryFcn);

expect(AppSettings.instance.settings).toEqual(overwriteSettings);
expect(recoveryFcn).toHaveBeenCalledTimes(1);
// expect(recoveryFcn).toHaveBeenCalledWith(fileName, defaultSettings); // Jest has a bug :) @TODO

// The below check doesn't work because jest doesn't clone arugments.
// expect(recoveryFcn).toHaveBeenCalledWith(fileName, defaultSettings);
});

it("should merge settings provided from the file", () => {
const settings = [
{
overrides: {
CredentialManager: "some-plugin"
}
},
{
abcd: "here"
}
];
});
});
});

0 comments on commit f3b045d

Please sign in to comment.