@patch('salt.modules.npm._check_valid_version',
           MagicMock(return_value=True))
    def test_cache_clean(self):
        mock = MagicMock(return_value={'retcode': 1, 'stderr': 'error'})
        with patch.dict(npm.__salt__, {'cmd.run_all': mock}):
            self.assertFalse(npm.cache_clean())

        mock = MagicMock(return_value={'retcode': 0})
        with patch.dict(npm.__salt__, {'cmd.run_all': mock}):
            self.assertTrue(npm.cache_clean())

        mock = MagicMock(return_value={'retcode': 0})
        with patch.dict(npm.__salt__, {'cmd.run_all': mock}):
            self.assertTrue(npm.cache_clean('coffee-script'))

    # 'cache_list' function tests: 1
Test if it cleans the cached NPM packages.
dataset/ETHPy150Open saltstack/salt/tests/unit/modules/npm_test.py/NpmTestCase.test_cache_clean