Skip to content

Commit

Permalink
- Remove obsolete karma test.
Browse files Browse the repository at this point in the history
  • Loading branch information
boyan-tonchev committed Aug 9, 2023
1 parent 3c9694e commit d7b960b
Showing 1 changed file with 0 additions and 117 deletions.
117 changes: 0 additions & 117 deletions test/resource/controllers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,123 +10,6 @@ beforeEach(angular.mock.module(function($provide) {
});
}));

describe('=> ExploreCtrl tests', function () {
var $repositories,
ClassInstanceDetailsService,
$httpBackend,
$location,
$controller,
$timeout,
$window,
$scope,
$jwtAuth,
$languageService;

beforeEach(angular.mock.inject(function (_$repositories_, _ClassInstanceDetailsService_, _$httpBackend_, _$location_, _$controller_, _$window_, _$timeout_, $rootScope, _$jwtAuth_, _$languageService_) {
$repositories = _$repositories_;
ClassInstanceDetailsService = _ClassInstanceDetailsService_;
$httpBackend = _$httpBackend_;
$location = _$location_;
$controller = _$controller_;
$window = _$window_;
$timeout = _$timeout_;
$jwtAuth = _$jwtAuth_;
$languageService = _$languageService_;

$scope = $rootScope.$new();

$jwtAuth.getPrincipal = function () {
return {
username: "user",
password: "",
confirmpassword: "",
authorities: ['ROLE_USER', 'WRITE_REPO_myrepo', 'READ_REPO_myrepo'],
appSettings: {'DEFAULT_INFERENCE': true, 'DEFAULT_SAMEAS': true, 'EXECUTE_COUNT': true}
}
}

$controller('ExploreCtrl', {$scope: $scope, $jwtAuth: $jwtAuth, $languageService: $languageService});

$httpBackend.when('GET', 'rest/security/all').respond(200, {
enabled: true,
freeAccess: {enabled: false},
overrideAuth: {enabled: false}
});

$httpBackend.when('GET', 'rest/security/authenticated-user').respond(401, 'Authentication required');
$httpBackend.when('GET', 'rest/locations').respond(200, {});
}));

afterEach(function () {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
});

describe('$scope.changeRole()', function () {
it('should set $scope.role correct nad call $scope.exploreResource()', function () {
$httpBackend.flush();
$scope.role = '';
spyOn($scope, 'exploreResource').and.callThrough();

$scope.changeRole('someRole');

expect($scope.role).toEqual('someRole');
expect($scope.exploreResource).toHaveBeenCalled();
})
});

describe('$scope.changeInference()', function () {
it('should set $scope.inference correct and call $scope.exploreResource()', function () {
$httpBackend.flush();
$scope.inference = '';
spyOn($scope, 'exploreResource').and.callThrough();

$scope.changeInference('inference');

expect($scope.inference).toEqual('inference');
expect($scope.exploreResource).toHaveBeenCalled();
})
});

describe('$scope.getLocalName()', function () {
it('should return undefined', function () {
$httpBackend.flush();
expect($scope.getLocalName()).toBeUndefined();
expect($scope.getLocalName(undefined)).toBeUndefined();
});

it('should return correct value', function () {
$httpBackend.flush();
expect($scope.getLocalName('some#test/string')).toEqual('string');
expect($scope.getLocalName('some/test#string')).toEqual('string');
expect($scope.getLocalName('someTest#string')).toEqual('string');
expect($scope.getLocalName('someTest/string')).toEqual('string');
})
})

describe('$scope.getRdfStarLocalNames()', function () {
it('should return triple resources correct local names', function () {
$httpBackend.flush();
const triple1 = '<<<http://www.wikidata.org/entity/S1> <http://www.wikidata.org/prop/P1> <http://www.wikidata.org/entity/O1>>>'
const triple2 = '<<<<<http://www.wikidata.org/entity/S1> <http://www.wikidata.org/prop/P1> <http://www.wikidata.org/entity/O1>>> <http://www.wikidata.org/prop/qualifier/P2> "datetime"^^<http://www.w3.org/2001/XMLSchema#xsd:dateTime>>>'
expect($scope.getRdfStarLocalNames(triple1)).toEqual('<<<S1> <P1> <O1>>>');
expect($scope.getRdfStarLocalNames(triple2)).toEqual('<<<<<S1> <P1> <O1>>> <P2> "datetime"^^<http://www.w3.org/2001/XMLSchema#xsd:dateTime>>>');

});
});


describe('$scope.isTripleResource()', function () {
it('should return true if triple resource', function () {
$httpBackend.flush();
$scope.tripleParam = '<<<S1> <P1> <O1>>>';

expect($scope.isTripleResource()).toBeTruthy();

});
});
});

describe('=> EditResourceCtrl', function () {
var $repositories,
$httpBackend,
Expand Down

0 comments on commit d7b960b

Please sign in to comment.