Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Change Preact require to thirdparty/preact (#13664)
Browse files Browse the repository at this point in the history
* Change Preact require to thirdparty/preact

* Address review comments
  • Loading branch information
boopeshmahendran authored and swmitra committed Sep 12, 2017
1 parent 7a1b9ff commit 1b37881
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 28 deletions.
3 changes: 2 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ require.config({
},
map: {
"*": {
"thirdparty/CodeMirror2": "thirdparty/CodeMirror"
"thirdparty/CodeMirror2": "thirdparty/CodeMirror",
"thirdparty/preact" : "preact-compat"
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/project/FileTreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
define(function (require, exports, module) {
"use strict";

var Preact = require("preact-compat"),
var Preact = require("thirdparty/preact"),
Classnames = require("thirdparty/classnames"),
Immutable = require("thirdparty/immutable"),
_ = require("thirdparty/lodash"),
Expand Down
6 changes: 6 additions & 0 deletions test/SpecRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ require.config({
"preact-test-utils" : "thirdparty/preact-test-utils/preact-test-utils",
"simulate-event" : "thirdparty/simulate-event/simulate-event",
"xtend" : "thirdparty/xtend"
},
map: {
"*": {
"thirdparty/preact" : "preact-compat",
"thirdparty/preact-test-utils" : "preact-test-utils"
}
}
});

Expand Down
52 changes: 26 additions & 26 deletions test/spec/FileTreeView-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ define(function (require, exports, module) {

var FileTreeView = require("project/FileTreeView"),
FileTreeViewModel = require("project/FileTreeViewModel"),
Preact = require("preact-compat"),
Preact = require("thirdparty/preact"),
Immutable = require("thirdparty/immutable"),
PTU = require("preact-test-utils"),
PreactTestUtils = require("thirdparty/preact-test-utils"),
_ = require("thirdparty/lodash");

// Preact Test Utils doesn't have findRenderedDOMComponentWithTag method
Expand All @@ -57,7 +57,7 @@ define(function (require, exports, module) {

describe("_fileNode", function () {
it("should create a component with the right information", function () {
var rendered = PTU.renderIntoDocument(FileTreeView._fileNode({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileNode({
name: "afile.js",
entry: Immutable.Map()
}));
Expand All @@ -70,7 +70,7 @@ define(function (require, exports, module) {

it("should call icon extensions to replace the default icon", function () {
var extensionCalls = 0,
rendered = PTU.renderIntoDocument(FileTreeView._fileNode({
rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileNode({
name: "afile.js",
entry: Immutable.Map(),
parentPath: "/foo/",
Expand All @@ -96,7 +96,7 @@ define(function (require, exports, module) {

it("should allow icon extensions to return a string for the icon", function () {
var extensionCalls = 0,
rendered = PTU.renderIntoDocument(FileTreeView._fileNode({
rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileNode({
name: "afile.js",
entry: Immutable.Map(),
parentPath: "/foo/",
Expand All @@ -123,30 +123,30 @@ define(function (require, exports, module) {

it("should set context on a node by right click", function () {
var actions = jasmine.createSpyObj("actions", ["setContext"]);
var rendered = PTU.renderIntoDocument(FileTreeView._fileNode({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileNode({
name: "afile.js",
entry: Immutable.Map(),
actions: actions,
parentPath: "/foo/"
}));
var node = Preact.findDOMNode(rendered);
PTU.Simulate.mouseDown(node, {
PreactTestUtils.Simulate.mouseDown(node, {
button: 2
});
expect(actions.setContext).toHaveBeenCalledWith("/foo/afile.js");
});

it("should set context on a node by control click on Mac", function () {
var actions = jasmine.createSpyObj("actions", ["setContext"]);
var rendered = PTU.renderIntoDocument(FileTreeView._fileNode({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileNode({
name: "afile.js",
entry: Immutable.Map(),
actions: actions,
parentPath: "/foo/",
platform: "mac"
}));
var node = Preact.findDOMNode(rendered);
PTU.Simulate.mouseDown(node, {
PreactTestUtils.Simulate.mouseDown(node, {
button: 0,
ctrlKey: true
});
Expand All @@ -155,15 +155,15 @@ define(function (require, exports, module) {

it("should not set context on a node by control click on Windows", function () {
var actions = jasmine.createSpyObj("actions", ["setContext"]);
var rendered = PTU.renderIntoDocument(FileTreeView._fileNode({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileNode({
name: "afile.js",
entry: Immutable.Map(),
actions: actions,
parentPath: "/foo/",
platform: "win"
}));
var node = Preact.findDOMNode(rendered);
PTU.Simulate.mouseDown(node, {
PreactTestUtils.Simulate.mouseDown(node, {
button: 0,
ctrlKey: true
});
Expand All @@ -172,7 +172,7 @@ define(function (require, exports, module) {

it("should allow icon extensions to return a jQuery object for the icon", function () {
var extensionCalls = 0,
rendered = PTU.renderIntoDocument(FileTreeView._fileNode({
rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileNode({
name: "afile.js",
entry: Immutable.Map(),
parentPath: "/foo/",
Expand All @@ -199,7 +199,7 @@ define(function (require, exports, module) {

it("should call addClass extensions", function () {
var extensionCalls = 0,
rendered = PTU.renderIntoDocument(FileTreeView._fileNode({
rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileNode({
name: "afile.js",
entry: Immutable.Map(),
parentPath: "/foo/",
Expand All @@ -223,7 +223,7 @@ define(function (require, exports, module) {
});

it("should render a rename component", function () {
var rendered = PTU.renderIntoDocument(FileTreeView._fileNode({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileNode({
name: "afile.js",
entry: Immutable.Map({
rename: true
Expand All @@ -241,7 +241,7 @@ define(function (require, exports, module) {
extensions: Immutable.Map()
};

var rendered = PTU.renderIntoDocument(FileTreeView._fileNode(props));
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileNode(props));

var newProps = _.clone(props);
expect(rendered.shouldComponentUpdate(newProps)).toBe(false);
Expand Down Expand Up @@ -317,7 +317,7 @@ define(function (require, exports, module) {

describe("_directoryNode and _directoryContents", function () {
it("should format a closed directory", function () {
var rendered = PTU.renderIntoDocument(FileTreeView._directoryNode({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._directoryNode({
name: "thedir",
parentPath: "/foo/",
entry: Immutable.fromJS({
Expand All @@ -342,7 +342,7 @@ define(function (require, exports, module) {
sortDirectoriesFirst: false
};

var rendered = PTU.renderIntoDocument(FileTreeView._directoryNode(props));
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._directoryNode(props));

var newProps = _.clone(props);

Expand Down Expand Up @@ -371,7 +371,7 @@ define(function (require, exports, module) {

it("should call extensions for directories", function () {
var extensionCalled = false,
rendered = PTU.renderIntoDocument(FileTreeView._directoryNode({
rendered = PreactTestUtils.renderIntoDocument(FileTreeView._directoryNode({
name: "thedir",
parentPath: "/foo/",
entry: Immutable.fromJS({
Expand Down Expand Up @@ -404,7 +404,7 @@ define(function (require, exports, module) {
});

it("should allow renaming a closed directory", function () {
var rendered = PTU.renderIntoDocument(FileTreeView._directoryNode({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._directoryNode({
name: "thedir",
entry: Immutable.fromJS({
children: null,
Expand All @@ -416,7 +416,7 @@ define(function (require, exports, module) {
});

it("should be able to list files", function () {
var rendered = PTU.renderIntoDocument(FileTreeView._directoryContents({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._directoryContents({
contents: Immutable.fromJS({
"afile.js": {}
})
Expand All @@ -427,7 +427,7 @@ define(function (require, exports, module) {
});

it("should be able to list closed directories", function () {
var rendered = PTU.renderIntoDocument(FileTreeView._directoryNode({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._directoryNode({
name: "thedir",
entry: Immutable.fromJS({
open: true,
Expand All @@ -445,7 +445,7 @@ define(function (require, exports, module) {
});

it("should be able to list open subdirectories", function () {
var rendered = PTU.renderIntoDocument(FileTreeView._directoryNode({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._directoryNode({
name: "twoLevel",
entry: twoLevel
}));
Expand All @@ -470,7 +470,7 @@ define(function (require, exports, module) {
open: true
});

var rendered = PTU.renderIntoDocument(FileTreeView._directoryNode({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._directoryNode({
name: "hasDirs",
entry: directory,
sortDirectoriesFirst: true
Expand All @@ -487,7 +487,7 @@ define(function (require, exports, module) {
extensions : Immutable.Map()
};

var rendered = PTU.renderIntoDocument(FileTreeView._directoryContents(props));
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._directoryContents(props));

var newProps = _.clone(props);

Expand Down Expand Up @@ -526,7 +526,7 @@ define(function (require, exports, module) {
});

it("should render the directory", function () {
var rendered = PTU.renderIntoDocument(FileTreeView._fileTreeView({
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileTreeView({
projectRoot: {},
treeData: new Immutable.Map({
"subdir": twoLevel.getIn(["children", "subdir"])
Expand All @@ -551,7 +551,7 @@ define(function (require, exports, module) {
extensions : Immutable.Map()
};

var rendered = PTU.renderIntoDocument(FileTreeView._fileTreeView(props));
var rendered = PreactTestUtils.renderIntoDocument(FileTreeView._fileTreeView(props));

var newProps = _.clone(props);

Expand Down

0 comments on commit 1b37881

Please sign in to comment.