Folders problem
by alexsuch
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/mocha/1.20.1/mocha.js"></script>
<link rel="stylesheet" href=" //cdnjs.cloudflare.com/ajax/libs/mocha/1.20.1/mocha.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/chai/1.9.1/chai.min.js"></script>
<div id="mocha"></div>
JavaScript
// Given a Folder class
class Folder {
constructor(name, parent) {
this.name = name;
this.parent = parent;
}
}
/*
Let's suppose a folder structure like the following:
Documents
╚ Pictures
╚ Vacation
Windows
╚ System32
*/
// Write a function that takes in a Folder object as a parameter and returns the full path of the given folder:
function getFullPath(folder) {
}
// Tests
mocha.setup('bdd');
var assert = chai.assert;
describe('getFullPath', function () {
const documents = new Folder('Documents', null);
const pictures = new Folder('Pictures', documents);
const vacation = new Folder('Vacation', pictures);
it('Documents', () => {
assert.equal(getFullPath(documents), 'Documents');
});
it('Pictures', () => {
assert.equal(getFullPath(pictures), 'Documents/Pictures');
});
it('Vacation', () => {
assert.equal(getFullPath(vacation), 'Documents/Pictures/Vacation');
});
});
mocha.run();