1
0
Fork 0

A frontend foxx model can now request it's configuration information

This commit is contained in:
Michael Hackstein 2015-01-29 15:38:03 +01:00
parent 368f78cda1
commit fd4d9ec116
2 changed files with 42 additions and 1 deletions

View File

@ -39,6 +39,21 @@
callback(err);
}
});
},
getConfiguration: function(callback) {
$.ajax({
type: "GET",
url: "/_admin/aardvark/foxxes/config?mount=" + this.encodedMount(),
contentType: "application/json",
processData: false,
success: function(data) {
callback(data);
},
error: function(err) {
callback(err);
}
});
}
});

View File

@ -1,7 +1,7 @@
/*jshint browser: true */
/*jshint unused: false */
/*global describe, beforeEach, afterEach, it, spyOn, expect*/
/*global $*/
/*global $, jasmine*/
(function() {
"use strict";
@ -35,6 +35,32 @@
var myFoxx = new window.Foxx();
expect(myFoxx.isNew()).toBeFalsy();
});
it("can get it's configuration", function() {
var data = {
opt1: {
type: "string",
description: "Option description",
default: "empty",
current: "empty"
}
};
var testMount = "/this/is_/a/test/mount";
var myFoxx = new window.Foxx({
mount: testMount
});
spyOn($, "ajax").andCallFake(function(opts) {
expect(opts.url).toEqual("/_admin/aardvark/foxxes/config?mount=" + myFoxx.encodedMount());
expect(opts.type).toEqual("GET");
expect(opts.success).toEqual(jasmine.any(Function));
expect(opts.error).toEqual(jasmine.any(Function));
opts.success(data);
});
myFoxx.getConfiguration(function(result) {
expect(result).toEqual(data);
});
expect($.ajax).toHaveBeenCalled();
});
});
}());