blob: c969141b62b7e5f196a1d06716185913642a110c [file] [log] [blame]
var shell = require('shelljs'),
path = require('path'),
fs = require('fs'),
prepareModule = require('../../template/cordova/lib/prepare'),
DUMMY_PROJECT_PATH = path.join(__dirname, '/fixtures/DummyProject'),
iconPath, currentProject;
describe('Cordova clean command', function() {
beforeEach(function() {
shell.cp('-rf', DUMMY_PROJECT_PATH, __dirname);
currentProject = path.join(__dirname, 'DummyProject');
iconPath = path.join(currentProject, 'images/SplashScreen.scale-100.png');
var fsExistsSyncOrig = fs.existsSync;
spyOn(fs, 'existsSync').andCallFake(function (filePath) {
if (/config\.xml$/.test(filePath)) return true;
return fsExistsSyncOrig(filePath);
});
});
afterEach(function() {
shell.rm('-rf', currentProject);
});
it('spec 1. should remove icons when ran inside Cordova project', function(done) {
var config = {
platform: 'windows',
root: currentProject,
locations: {
root: currentProject,
configXml: path.join(currentProject, 'config.xml'),
www: path.join(currentProject, 'www')
}
};
var rejected = jasmine.createSpy();
prepareModule.clean.call(config)
.then(function() {
expect(fs.existsSync(iconPath)).toBeFalsy();
}, rejected)
.finally(function() {
expect(rejected).not.toHaveBeenCalled();
done();
});
});
});