| 1 |
/* testPathsViewer.js |
| 2 |
* |
| 3 |
* Copyright 2020 Martin Abente Lahaye |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
const {setup} = imports.utils; |
| 20 |
setup(); |
| 21 |
|
| 22 |
const {FlatsealPathsViewer} = imports.widgets.pathsViewer; |
| 23 |
const {FlatsealPathRow} = imports.widgets.pathRow; |
| 24 |
|
| 25 |
const _paths = 'home;host;xdg-desktop'; |
| 26 |
|
| 27 |
|
| 28 |
describe('FlatsealPathsViewer', function() { |
| 29 |
var viewer; |
| 30 |
|
| 31 |
beforeEach(function() { |
| 32 |
viewer = new FlatsealPathsViewer( |
| 33 |
(v) => v.join(';'), |
| 34 |
(v) => v.split(';'), |
| 35 |
FlatsealPathRow, |
| 36 |
); |
| 37 |
}); |
| 38 |
|
| 39 |
it('starts empty', function() { |
| 40 |
expect(viewer.text).toEqual(''); |
| 41 |
}); |
| 42 |
|
| 43 |
it('processes paths correctly', function() { |
| 44 |
viewer.text = _paths; |
| 45 |
expect(viewer.text).toEqual(_paths); |
| 46 |
}); |
| 47 |
|
| 48 |
it('handles new paths', function() { |
| 49 |
viewer.text = _paths; |
| 50 |
viewer.add('~/Steam'); |
| 51 |
expect(viewer.text).toEqual(`${_paths};~/Steam`); |
| 52 |
}); |
| 53 |
|
| 54 |
it('resets paths', function() { |
| 55 |
viewer.add(''); |
| 56 |
viewer.text = ''; |
| 57 |
expect(viewer.text).toEqual(''); |
| 58 |
}); |
| 59 |
}); |