Skip to content

Commit 88a8ebe

Browse files
committed
test: tests for loading extension from custom path
1 parent f1e7eeb commit 88a8ebe

File tree

7 files changed

+78
-3
lines changed

7 files changed

+78
-3
lines changed

src/utils/ExtensionLoader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ define(function (require, exports, module) {
494494
}
495495

496496
/**
497-
* Loads a given extension at the path from native directory.
497+
* Loads a given extension at the path from virtual fs.
498498
* @param directory
499499
* @return {!Promise}
500500
*/
@@ -695,6 +695,7 @@ define(function (require, exports, module) {
695695
exports.loadExtension = loadExtension;
696696
exports.testExtension = testExtension;
697697
exports.loadAllExtensionsInNativeDirectory = loadAllExtensionsInNativeDirectory;
698+
exports.loadExtensionFromNativeDirectory = loadExtensionFromNativeDirectory;
698699
exports.testAllExtensionsInNativeDirectory = testAllExtensionsInNativeDirectory;
699700
exports.testAllDefaultExtensions = testAllDefaultExtensions;
700701
exports.EVENT_EXTENSION_LOADED = EVENT_EXTENSION_LOADED;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*global define, brackets, $ */
2+
3+
define(function (require, exports, module) {
4+
"use strict";
5+
6+
// Brackets modules
7+
var AppInit = brackets.getModule("utils/AppInit");
8+
9+
// Initialize extension once shell is finished initializing.
10+
AppInit.appReady(function () {
11+
console.log("hello world");
12+
window.extensionLoaderTestExtensionLoaded = true;
13+
});
14+
15+
});
16+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "hello.test",
3+
"title": "All New Extension Store Test Extension.",
4+
"description": "Test extension for new extension publish workflow.",
5+
"homepage": "https://github.com/test/repo",
6+
"version": "0.0.8",
7+
"author": "Arun",
8+
"license": "MIT",
9+
"categories": "demo",
10+
"keywords": [
11+
"phcode", "extension", "demo"
12+
],
13+
"files": [
14+
"main.js"
15+
],
16+
"engines": {
17+
"brackets": ">=0.34.0"
18+
}
19+
}
20+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"title": "da theme",
3+
"name": "da-theme",
4+
"description": "da theme",
5+
"version": "1.0.1",
6+
"license": "MIT",
7+
"author": "da theme",
8+
"homepage": "da theme",
9+
"engines": {
10+
"brackets": ">=0.42.0"
11+
},
12+
"theme": {
13+
"file": "theme.css",
14+
"dark": true
15+
}
16+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#sidebar{
2+
background-color: #334646;
3+
}

test/spec/ExtensionLoader-test.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
*/
2121

2222
/*jslint regexp: true */
23-
/*global describe, it, spyOn, expect, beforeEach, afterEach, awaitsForFail, awaitsForDone */
23+
/*global describe, it, spyOn, expect, beforeEach, afterEach, awaitsForFail, awaitsForDone, awaitsFor */
2424

2525
define(function (require, exports, module) {
2626

2727

2828
// Load dependent modules
2929
var ExtensionLoader = require("utils/ExtensionLoader"),
30+
ThemeManager = require("view/ThemeManager"),
3031
SpecRunnerUtils = require("spec/SpecRunnerUtils");
3132

3233
const testPath = SpecRunnerUtils.getTestPath("/spec/ExtensionLoader-test-files");
@@ -125,5 +126,23 @@ define(function (require, exports, module) {
125126
await testLoadExtension("BadRequireConfig", "resolved", /^\[Extension\] The require config file provided is invalid/);
126127
});
127128

129+
it("should load a custom extension", async function () {
130+
await awaitsForDone(ExtensionLoader.loadExtensionFromNativeDirectory(`${testPath}/extension`));
131+
expect(window.extensionLoaderTestExtensionLoaded).toBeTrue();
132+
});
133+
134+
it("should load a custom theme", async function () {
135+
await awaitsForDone(ExtensionLoader.loadExtensionFromNativeDirectory(`${testPath}/theme`));
136+
expect(window.extensionLoaderTestExtensionLoaded).toBeTrue();
137+
await awaitsFor(function () {
138+
let themes = ThemeManager.getAllThemes();
139+
for(let theme of themes){
140+
if(theme.name === "da-theme"){
141+
return true;
142+
}
143+
}
144+
return false;
145+
}, "custom theme to be loaded");
146+
});
128147
});
129148
});

test/virtual-server-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function getRoute(){
3737
return `${basePath}/phoenix/vfs`;
3838
}
3939

40-
window.fsServerUrl = window.location.origin + getRoute();
40+
window.fsServerUrl = window.location.origin + getRoute() + "/";
4141

4242
function serverReady() {
4343
console.log(`Server ready! Serving files on url: ${window.location.origin + getRoute()}`);

0 commit comments

Comments
 (0)