Skip to content

Commit

Permalink
feat: package sends value for document.title if activated
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorstenSuckow committed May 8, 2022
1 parent e3942fd commit 37e5267
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 7 deletions.
1 change: 1 addition & 0 deletions resources/extjs-app-imapuser.conf.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"title": "Login",
"service": {
"rest-imapuser" : {
"base" : "https://php-ms-imapuser.ddev.site/rest-imapuser/api/v0/"
Expand Down
3 changes: 3 additions & 0 deletions src/app/PackageController.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ Ext.define("conjoon.cn_imapuser.app.PackageController", {
return true;
}

let title = app.getPackageConfig(me, "title");
title && Ext.fireEvent("conjoon.application.TitleAvailable", me, title);

if (username && password) {
coon.user.Manager.loadUser({
params: {
Expand Down
23 changes: 16 additions & 7 deletions tests/groups.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* conjoon
* extjs-app-imapuser
* Copyright (C) 2017-2021 Thorsten Suckow-Homberg https://github.com/conjoon/extjs-app-imapuser
* Copyright (C) 2017-2022 Thorsten Suckow-Homberg https://github.com/conjoon/extjs-app-imapuser
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -70,11 +70,20 @@ export default [{
}]
}, {
group: "universal",
items: [
"src/UserProviderTest.js", {
group: "app",
items: [
"src/app/PackageControllerTest.js"
]
items: [{
group: "_issues_",
items: [{
group: "feat",
items: [{
name: "conjoon/conjoon#7",
url: "src/_issues_/feat/conjoon%237.js"
}]
}]
}, {
group: "app",
items: [
"src/app/PackageControllerTest.js"
]
},
"src/UserProviderTest.js"]
}];
72 changes: 72 additions & 0 deletions tests/src/_issues_/feat/conjoon#7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* conjoon
* extjs-app-imapuser
* Copyright (C) 2022 Thorsten Suckow-Homberg https://github.com/conjoon/extjs-app-imapuser
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

StartTest(t => {

t.diag("feat: title of app should be set once configuration is available conjoon/conjoon#7");


// +----------------------------------------------------------------------------
// | =~. Unit Tests .~=
// +----------------------------------------------------------------------------


t.it("preLaunchHook()", t => {

let FAKE_TITLE = "PACKAGE_TITLE";

const
ctrl = Ext.create("conjoon.cn_imapuser.app.PackageController"),
fakeCookies = {},
fakeApp = {getPackageConfig: function (){return FAKE_TITLE;}, activateViewForHash: () => {}},
spy = t.spyOn(fakeApp, "getPackageConfig"),
fireSpy = t.spyOn(Ext, "fireEvent");

ctrl.getCookies = () => fakeCookies;
ctrl.createAuthWindow = () => {};

ctrl.preLaunchHook(fakeApp);

t.isDeeplyStrict(spy.calls.mostRecent().args, [ctrl, "title"]);
t.isDeeplyStrict(fireSpy.calls.mostRecent().args, ["conjoon.application.TitleAvailable", ctrl, FAKE_TITLE]);

FAKE_TITLE = undefined;
ctrl.preLaunchHook(fakeApp);
t.expect(fireSpy.calls.count()).toBe(1);

FAKE_TITLE = "truthy";
ctrl.preLaunchHook(fakeApp);
t.expect(fireSpy.calls.count()).toBe(2);

coon.user.Manager.getUser = () => ({});
ctrl.preLaunchHook(fakeApp);
t.expect(fireSpy.calls.count()).toBe(2);

[spy, fireSpy].map(spy => spy.remove());

});


});

0 comments on commit 37e5267

Please sign in to comment.