"use strict";

var _mockFs = _interopRequireDefault(require("mock-fs"));

var _fs = _interopRequireDefault(require("fs"));

var _path = _interopRequireDefault(require("path"));

var _deleteFilesInFolder = _interopRequireDefault(require("./deleteFilesInFolder"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

describe('Delete Files in Folder', () => {
  const PATH_DIR = './fakeDir';
  beforeEach(() => {
    (0, _mockFs.default)({
      './fakeDir': {
        'web.html': 'test',
        'img.png': 'test'
      }
    });
  });
  afterEach(() => {
    _mockFs.default.restore();
  });
  test('should delete files in folder', () => {
    (0, _deleteFilesInFolder.default)(PATH_DIR);

    const file = _path.default.join(PATH_DIR, 'web.html');

    expect(_fs.default.existsSync(file)).toBeFalsy();
  });
  test('should not delete unwanted files in folder', () => {
    (0, _deleteFilesInFolder.default)(PATH_DIR, 'html');

    const fileDeleted = _path.default.join(PATH_DIR, 'web.html');

    const fileExist = _path.default.join(PATH_DIR, 'img.png');

    expect(_fs.default.existsSync(fileDeleted)).toBeFalsy();
    expect(_fs.default.existsSync(fileExist)).toBeTruthy();
  });
});