import { isDownloadStatusMessage, isInstallStatusMessage, validateStatusMessage} from "./statusMessage";

describe("validatons", () => {
  it("isDownloadStatusMessage", () => {
    expect(isDownloadStatusMessage({ msg: "download_start"})).toEqual(true);
    expect(isDownloadStatusMessage({ msg: "downloading"})).toEqual(true);
    expect(isDownloadStatusMessage({ msg: "download_complete"})).toEqual(true);
    expect(isDownloadStatusMessage({ msg: "download_error"})).toEqual(true);
    expect(isDownloadStatusMessage({ msg: "package_download_complete"})).toEqual(true);
    
    expect(isDownloadStatusMessage({ msg: "installing"})).toEqual(false);
    expect(isDownloadStatusMessage({ msg: "install_start"})).toEqual(false);
    expect(isDownloadStatusMessage({ msg: "install_complete"})).toEqual(false);
    expect(isDownloadStatusMessage({ msg: "install_error"})).toEqual(false);
    expect(isDownloadStatusMessage({ msg: "pacakge_install_complete"})).toEqual(false);
  });
  it("isInstallStatusMessage", () => {
    expect(isInstallStatusMessage({ msg: "download_start"})).toEqual(false);
    expect(isInstallStatusMessage({ msg: "downloading"})).toEqual(false);
    expect(isInstallStatusMessage({ msg: "download_complete"})).toEqual(false);
    expect(isInstallStatusMessage({ msg: "download_error"})).toEqual(false);
    expect(isInstallStatusMessage({ msg: "package_download_complete"})).toEqual(false);
    
    expect(isInstallStatusMessage({ msg: "installing"})).toEqual(true);
    expect(isInstallStatusMessage({ msg: "install_start"})).toEqual(true);
    expect(isInstallStatusMessage({ msg: "install_complete"})).toEqual(true);
    expect(isInstallStatusMessage({ msg: "install_error"})).toEqual(true);
    expect(isInstallStatusMessage({ msg: "pacakge_install_complete"})).toEqual(true);
  });
  it("validateStatusMessage", () => {
    expect(validateStatusMessage({ msg: "download_start", package_current: 0, package_total: 0})).toEqual(true);
    expect(validateStatusMessage({ msg: "downloading", package_current: 0, package_total: 0})).toEqual(true);
    expect(validateStatusMessage({ msg: "download_complete", package_current: 0, package_total: 0})).toEqual(true);
    expect(validateStatusMessage({ msg: "download_error", package_current: 0, package_total: 0})).toEqual(true);
    expect(validateStatusMessage({ msg: "package_download_complete", package_current: 0, package_total: 0})).toEqual(true);
    
    expect(validateStatusMessage({ msg: "installing", installed: 0, total_files: 0 })).toEqual(true);
    expect(validateStatusMessage({ msg: "install_start", installed: 0, total_files: 0 })).toEqual(true);
    expect(validateStatusMessage({ msg: "install_complete", installed: 0, total_files: 0 })).toEqual(true);
    expect(validateStatusMessage({ msg: "install_error", installed: 0, total_files: 0 })).toEqual(true);
    expect(validateStatusMessage({ msg: "pacakge_install_complete", installed: 0, total_files: 0 })).toEqual(true);

    expect(validateStatusMessage({ msg: "downloading", package_current: -1, package_total: -1})).toEqual(false);
    expect(validateStatusMessage({ msg: "installing", installed: -1, total_files: -1})).toEqual(false);
    expect(validateStatusMessage({ msg: "download_start", package_current: 100, package_total: 50})).toEqual(false);
    expect(validateStatusMessage({ msg: "install_start", installed: 10, total_files: 9})).toEqual(false);
  });
})