Skip to content

Commit 68a1c51

Browse files
committed
added tests for urls with suffixes
1 parent 5218d60 commit 68a1c51

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

test/restangularSpec.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,41 @@ describe("Restangular", function() {
293293

294294
});
295295

296-
describe("With Url", function() {
297-
it("Shouldn't add suffix to URL", function() {
296+
describe("With Suffix", function() {
297+
it("shouldn't add suffix to getRestangularUrl", function() {
298298
var suffixRestangular = Restangular.withConfig(function(RestangularConfigurer) {
299299
RestangularConfigurer.setRequestSuffix('.json');
300300
});
301+
var collection = suffixRestangular.all('accounts');
302+
expect(collection.getRestangularUrl()).toBe('/accounts');
303+
expect(collection.one('1').getRestangularUrl()).toBe('/accounts/1');
304+
});
305+
306+
it("should add suffix to getRequestedUrl", function() {
307+
var suffixRestangular = Restangular.withConfig(function(RestangularConfigurer) {
308+
RestangularConfigurer.setRequestSuffix('.json');
309+
});
310+
var collection = suffixRestangular.all('accounts');
311+
expect(collection.getRequestedUrl()).toBe('/accounts.json');
312+
expect(collection.one('1').getRequestedUrl()).toBe('/accounts/1.json');
313+
});
314+
315+
it("should add suffix to request", function() {
316+
var suffixRestangular = Restangular.withConfig(function(RestangularConfigurer) {
317+
RestangularConfigurer.setRequestSuffix('.json');
318+
});
319+
var collection = suffixRestangular.all('accounts');
320+
$httpBackend.expectGET('/accounts.json').respond(200);
321+
$httpBackend.expectGET('/accounts/1.json').respond(200);
322+
collection.getList();
323+
collection.get('1');
324+
$httpBackend.flush();
325+
});
301326

327+
it("shouldn't add suffix to allUrl", function() {
328+
var suffixRestangular = Restangular.withConfig(function(RestangularConfigurer) {
329+
RestangularConfigurer.setRequestSuffix('.json');
330+
});
302331
$httpBackend.expectGET('http://accounts.com/all');
303332
suffixRestangular.allUrl('accounts', 'http://accounts.com/all').getList();
304333
$httpBackend.flush();

0 commit comments

Comments
 (0)