-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
152 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
libs/vscode/nx-project-view/src/lib/views/nx-project-tree-view.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { ViewDataProvider } from './nx-project-base-view' | ||
import { createTreeViewStrategy } from './nx-project-tree-view' | ||
|
||
describe('Project View: TreeView', () => { | ||
describe('nx workspace', () => { | ||
it('should find root directories', async () => { | ||
const viewProvider = createMockViewDataProvider(nxExample.workspacePath, nxExample.project) | ||
const treeView = createTreeViewStrategy(viewProvider) | ||
|
||
const rootElements = await treeView.getChildren(); | ||
expect(rootElements).toHaveLength(2) | ||
const paths = rootElements?.map((e) => e.label) | ||
expect(paths).toEqual(['apps', 'libs']) | ||
}) | ||
}) | ||
}) | ||
|
||
type MockDataGetWorkspacePath = ReturnType<ViewDataProvider['getWorkspacePath']> | ||
type MockDataGetProjects = Awaited<ReturnType<ViewDataProvider['getProjects']>> | ||
|
||
function createMockViewDataProvider(workspacePath: MockDataGetWorkspacePath, projects: unknown): ViewDataProvider { | ||
return { | ||
getWorkspacePath: () => workspacePath, | ||
getProjects: () => new Promise(resolve => setTimeout(() => resolve(projects as MockDataGetProjects))) | ||
} | ||
} | ||
|
||
// Result of cliTaskProvider.getProjects() for apps/vscode-e2e/testworkspaces/testworkspace-nx | ||
const nxExample = { | ||
workspacePath: '/git/nx-console/apps/vscode-e2e/testworkspaces/testworkspace-nx', | ||
project: { | ||
"app1": { | ||
"targets": { | ||
"build": { | ||
"executor": "@nrwl/webpack:webpack", | ||
"configurations": { | ||
"production": { | ||
|
||
} | ||
}, | ||
"dependsOn": [ | ||
"^build" | ||
], | ||
"inputs": [ | ||
"production", | ||
"^production" | ||
] | ||
}, | ||
"test": { | ||
"executor": "@nrwl/jest:jest" | ||
} | ||
}, | ||
"root": "apps/app1", | ||
"tags": [ | ||
|
||
], | ||
"files": [ | ||
{ | ||
"file": "apps/app1/app1.js", | ||
"hash": "fda9bc547f3d044be11c43ba8df3b8f387f29532", | ||
"deps": [ | ||
"lib1", | ||
"lib2" | ||
] | ||
}, | ||
{ | ||
"file": "apps/app1/project.json", | ||
"hash": "5b8dd29636672949793a788e40c9f39b75aadc99" | ||
} | ||
] | ||
}, | ||
"lib1": { | ||
"targets": { | ||
"test": { | ||
"executor": "@nrwl/jest:jest" | ||
} | ||
}, | ||
"root": "libs/lib1", | ||
"tags": [ | ||
|
||
], | ||
"files": [ | ||
{ | ||
"file": "libs/lib1/project.json", | ||
"hash": "929b00c99a39f3bb085b2487fed80d8e8421aea7" | ||
}, | ||
{ | ||
"file": "libs/lib1/src/index.ts", | ||
"hash": "56e2812af30c82f0f15bb726f98a27321363e5ca" | ||
}, | ||
{ | ||
"file": "libs/lib1/src/lib/lib1.js", | ||
"hash": "f63c731f25f9ac8efaaee3420cac1e7f08185169" | ||
} | ||
] | ||
}, | ||
"lib2": { | ||
"targets": { | ||
"test": { | ||
"executor": "@nrwl/jest:jest" | ||
}, | ||
"weird": { | ||
|
||
} | ||
}, | ||
"root": "libs/lib2", | ||
"tags": [ | ||
|
||
], | ||
"files": [ | ||
{ | ||
"file": "libs/lib2/project.json", | ||
"hash": "157a68f9115ba2aeb01e074404066c7aef10c34b" | ||
}, | ||
{ | ||
"file": "libs/lib2/src/index.js", | ||
"hash": "9aeaf007321d35731cf3a05e937f966216376c95" | ||
}, | ||
{ | ||
"file": "libs/lib2/src/lib/lib2.js", | ||
"hash": "fcc28489c736ebac8fe0b1b4f3c2aa3041a0de8e" | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters