1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-25 00:09:40 +02:00
portainer/test/unit/app/components/volumesController.spec.js
Chaim Lev-Ari cf5056d9c0
chore(project): add prettier for code format (#3645)
* chore(project): install prettier and lint-staged

* chore(project): apply prettier to html too

* chore(project): git ignore eslintcache

* chore(project): add a comment about format script

* chore(prettier): update printWidth

* chore(prettier): remove useTabs option

* chore(prettier): add HTML validation

* refactor(prettier): fix closing tags

* feat(prettier): define angular parser for html templates

* style(prettier): run prettier on codebase

Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
2020-04-11 09:54:53 +12:00

63 lines
1.7 KiB
JavaScript

describe('VolumesController', function () {
var $scope, $httpBackend, $routeParams;
beforeEach(module('portainer'));
beforeEach(inject(function (_$httpBackend_, $controller, _$routeParams_) {
$scope = {};
$httpBackend = _$httpBackend_;
$routeParams = _$routeParams_;
$controller('VolumesController', {
$scope: $scope,
$routeParams: $routeParams,
});
}));
it('initializes correctly', function () {
expectGetVolumes();
$httpBackend.flush();
});
it('issues correct remove calls to the remote API', function () {
expectGetVolumes();
$httpBackend.flush();
$scope.volumes[0].Checked = true;
$scope.volumes[2].Checked = true;
$httpBackend.expectDELETE('dockerapi/volumes/tardis').respond(200);
$httpBackend.expectDELETE('dockerapi/volumes/bar').respond(200);
$scope.removeAction();
$httpBackend.flush();
});
it('issues a correct volume creation call to the remote API', function () {
expectGetVolumes();
var createBody = {
Name: 'tardis',
Driver: 'local',
};
$httpBackend.expectPOST('dockerapi/volumes/create', createBody).respond(201);
expectGetVolumes();
$scope.addVolume(createBody);
$httpBackend.flush();
});
function expectGetVolumes() {
$httpBackend.expectGET('dockerapi/volumes').respond({
Volumes: [
{
Name: 'tardis',
Driver: 'local',
Mountpoint: '/var/lib/docker/volumes/tardis',
},
{
Name: 'foo',
Driver: 'local',
Mountpoint: '/var/lib/docker/volumes/foo',
},
{
Name: 'bar',
Driver: 'local',
Mountpoint: '/var/lib/docker/volumes/bar',
},
],
});
}
});