feat(module,app): basic module to list apps
This commit is contained in:
@ -25,6 +25,7 @@
|
||||
<script src="/test/net-module.js"></script>
|
||||
<script src="/test/rpc-module.js"></script>
|
||||
<script src="/test/file-module.js"></script>
|
||||
<script src="/test/app-module.js"></script>
|
||||
<script class="mocha-exec">
|
||||
mocha.run();
|
||||
</script>
|
||||
|
37
misc/client-sdk-testsuite/src/public/test/app-module.js
Normal file
37
misc/client-sdk-testsuite/src/public/test/app-module.js
Normal file
@ -0,0 +1,37 @@
|
||||
describe('App Module', function() {
|
||||
|
||||
before(() => {
|
||||
return Edge.connect();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
Edge.disconnect();
|
||||
});
|
||||
|
||||
it('should list apps', function() {
|
||||
return Edge.rpc("listApps")
|
||||
.then(apps => {
|
||||
console.log("listApps result:", apps);
|
||||
chai.assert.isNotNull(apps);
|
||||
chai.assert.isAtLeast(apps.length, 1);
|
||||
})
|
||||
});
|
||||
|
||||
it('should retrieve requested app', function() {
|
||||
return Edge.rpc("getApp", { appId: "edge.sdk.client.test" })
|
||||
.then(app => {
|
||||
console.log("getApp result:", app);
|
||||
chai.assert.isNotNull(app);
|
||||
chai.assert.equal(app.id, "edge.sdk.client.test");
|
||||
})
|
||||
});
|
||||
|
||||
it('should retrieve requested app url', function() {
|
||||
return Edge.rpc("getAppUrl", { appId: "edge.sdk.client.test" })
|
||||
.then(url => {
|
||||
console.log("getAppUrl result:", url);
|
||||
chai.assert.isNotEmpty(url);
|
||||
})
|
||||
});
|
||||
|
||||
});
|
@ -11,6 +11,10 @@ function onInit() {
|
||||
rpc.register("reset", reset);
|
||||
rpc.register("total", total);
|
||||
rpc.register("getUserInfo", getUserInfo);
|
||||
|
||||
rpc.register("listApps");
|
||||
rpc.register("getApp");
|
||||
rpc.register("getAppUrl");
|
||||
}
|
||||
|
||||
// Called for each client message
|
||||
@ -79,4 +83,18 @@ function getUserInfo(ctx, params) {
|
||||
role: role,
|
||||
preferredUsername: preferredUsername,
|
||||
};
|
||||
}
|
||||
|
||||
function listApps(ctx) {
|
||||
return app.list(ctx);
|
||||
}
|
||||
|
||||
function getApp(ctx, params) {
|
||||
var appId = params.appId;
|
||||
return app.get(ctx, appId);
|
||||
}
|
||||
|
||||
function getAppUrl(ctx, params) {
|
||||
var appId = params.appId;
|
||||
return app.getUrl(ctx, appId);
|
||||
}
|
Reference in New Issue
Block a user