1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var fs = require("fs-extra");
  4. var clean = require("./clean");
  5. describe('clean task', function () {
  6. describe('clean', function () {
  7. it('should empty the build directory', function () {
  8. // arrage
  9. spyOn(fs, fs.emptyDirSync.name).and.returnValue('things');
  10. var context = { buildDir: 'something' };
  11. // act
  12. return clean.clean(context).then(function () {
  13. // assert
  14. expect(fs.emptyDirSync).toHaveBeenCalledWith(context.buildDir);
  15. });
  16. });
  17. it('should throw when failing to empty dir', function () {
  18. // arrage
  19. spyOn(fs, fs.emptyDirSync.name).and.throwError('Simulating an error');
  20. var context = { buildDir: 'something' };
  21. // act
  22. return clean.clean(context).catch(function (ex) {
  23. expect(ex instanceof Error).toBe(true);
  24. expect(typeof ex.message).toBe('string');
  25. });
  26. });
  27. });
  28. });