def METHOD_NAME():
    """
    Test to verify that the npm cache is cleaned.
    """
    name = "coffee-script"
    pkg_ret = {"name": name, "result": False, "comment": "", "changes": {}}
    ret = {"name": None, "result": False, "comment": "", "changes": {}}
    mock_list = MagicMock(return_value=["~/.npm", "~/.npm/{}/".format(name)])
    mock_cache_clean_success = MagicMock(return_value=True)
    mock_cache_clean_failure = MagicMock(return_value=False)
    mock_err = MagicMock(side_effect=CommandExecutionError)
    with patch.dict(npm.__salt__, {"npm.cache_list": mock_err}):
        comt = "Error looking up cached packages: "
        ret.update({"comment": comt})
        assert npm.cache_cleaned() == ret
    with patch.dict(npm.__salt__, {"npm.cache_list": mock_err}):
        comt = "Error looking up cached {}: ".format(name)
        pkg_ret.update({"comment": comt})
        assert npm.cache_cleaned(name) == pkg_ret
    mock_data = {"npm.cache_list": mock_list, "npm.cache_clean": MagicMock()}
    with patch.dict(npm.__salt__, mock_data):
        non_cached_pkg = "salt"
        comt = "Package {} is not in the cache".format(non_cached_pkg)
        pkg_ret.update({"name": non_cached_pkg, "result": True, "comment": comt})
        assert npm.cache_cleaned(non_cached_pkg) == pkg_ret
        pkg_ret.update({"name": name})
        with patch.dict(npm.__opts__, {"test": True}):
            comt = "Cached packages set to be removed"
            ret.update({"result": None, "comment": comt})
            assert npm.cache_cleaned() == ret
        with patch.dict(npm.__opts__, {"test": True}):
            comt = "Cached {} set to be removed".format(name)
            pkg_ret.update({"result": None, "comment": comt})
            assert npm.cache_cleaned(name) == pkg_ret
        with patch.dict(npm.__opts__, {"test": False}):
            comt = "Cached packages successfully removed"
            ret.update(
                {"result": True, "comment": comt, "changes": {"cache": "Removed"}}
            )
            assert npm.cache_cleaned() == ret
        with patch.dict(npm.__opts__, {"test": False}):
            comt = "Cached {} successfully removed".format(name)
            pkg_ret.update(
                {"result": True, "comment": comt, "changes": {name: "Removed"}}
            )
            assert npm.cache_cleaned(name) == pkg_ret
    mock_data = {
        "npm.cache_list": mock_list,
        "npm.cache_clean": MagicMock(return_value=False),
    }
    with patch.dict(npm.__salt__, mock_data):
        with patch.dict(npm.__opts__, {"test": False}):
            comt = "Error cleaning cached packages"
            ret.update({"result": False, "comment": comt})
            ret["changes"] = {}
            assert npm.cache_cleaned() == ret
        with patch.dict(npm.__opts__, {"test": False}):
            comt = "Error cleaning cached {}".format(name)
            pkg_ret.update({"result": False, "comment": comt})
            pkg_ret["changes"] = {}
            assert npm.cache_cleaned(name) == pkg_ret