uninstall.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. var path = require('path');
  2. var expect = require('expect.js');
  3. var fs = require('fs');
  4. var helpers = require('../helpers');
  5. var bower = helpers.require('lib/index');
  6. describe('bower uninstall', function () {
  7. var tempDir = new helpers.TempDir({
  8. 'bower.json': {
  9. name: 'hello-world',
  10. dependencies: {
  11. 'underscore': '*'
  12. }
  13. }
  14. });
  15. beforeEach(function() {
  16. tempDir.prepare();
  17. });
  18. var bowerJsonPath = path.join(tempDir.path, 'bower.json');
  19. function bowerJson() {
  20. return JSON.parse(fs.readFileSync(bowerJsonPath));
  21. }
  22. var config = {
  23. cwd: tempDir.path,
  24. interactive: true
  25. };
  26. it('does not remove anything from dependencies by default', function () {
  27. var logger = bower.commands.uninstall(['underscore'], undefined, config);
  28. return helpers.expectEvent(logger, 'end')
  29. .then(function () {
  30. expect(bowerJson().dependencies).to.eql({ 'underscore': '*' });
  31. });
  32. });
  33. it('removes dependency from bower.json if --save flag is used', function () {
  34. var logger = bower.commands.uninstall(['underscore'], {save: true}, config);
  35. return helpers.expectEvent(logger, 'end')
  36. .then(function () {
  37. expect(bowerJson().dependencies).to.eql({});
  38. });
  39. });
  40. });