@@ -4,8 +4,9 @@ import Project from '../Project';
44import Package from '../Package' ;
55import Workspace from '../Workspace' ;
66import * as logger from '../utils/logger' ;
7+ import fixtures from 'fixturez' ;
78
8- import { getFixturePath } from 'jest- fixtures' ;
9+ const f = fixtures ( __dirname ) ;
910
1011jest . mock ( '../utils/logger' ) ;
1112
@@ -34,7 +35,7 @@ describe('Project', () => {
3435
3536 describe ( 'A simple project' , ( ) => {
3637 beforeEach ( async ( ) => {
37- const filePath = await getFixturePath ( __dirname , 'simple-project' ) ;
38+ let filePath = f . find ( 'simple-project' ) ;
3839 project = await Project . init ( filePath ) ;
3940 } ) ;
4041
@@ -44,14 +45,14 @@ describe('Project', () => {
4445 } ) ;
4546
4647 it ( 'should be able to getWorkspaces' , async ( ) => {
47- const workspaces = await project . getWorkspaces ( ) ;
48+ let workspaces = await project . getWorkspaces ( ) ;
4849 expect ( workspaces . length ) . toEqual ( 2 ) ;
4950 expect ( workspaces [ 0 ] ) . toBeInstanceOf ( Workspace ) ;
5051 } ) ;
5152
5253 it ( 'should be able to runWorkspaceTasks' , async ( ) => {
53- const workspaces = await project . getWorkspaces ( ) ;
54- const spy = jest . fn ( ( ) => Promise . resolve ( ) ) ;
54+ let workspaces = await project . getWorkspaces ( ) ;
55+ let spy = jest . fn ( ( ) => Promise . resolve ( ) ) ;
5556
5657 await project . runWorkspaceTasks ( workspaces , spy ) ;
5758
@@ -63,20 +64,20 @@ describe('Project', () => {
6364
6465 describe ( 'A project with nested workspaces' , ( ) => {
6566 beforeEach ( async ( ) => {
66- const filePath = await getFixturePath ( __dirname , 'nested-workspaces' ) ;
67+ let filePath = f . find ( 'nested-workspaces' ) ;
6768 project = await Project . init ( filePath ) ;
6869 } ) ;
6970
7071 it ( 'should be able to getWorkspaces (including nested)' , async ( ) => {
71- const workspaces = await project . getWorkspaces ( ) ;
72+ let workspaces = await project . getWorkspaces ( ) ;
7273 expect ( workspaces . length ) . toEqual ( 3 ) ;
7374 expect ( workspaces [ 0 ] ) . toBeInstanceOf ( Workspace ) ;
7475 } ) ;
7576
7677 it ( 'should be able to getDependencyGraph' , async ( ) => {
77- const workspaces = await project . getWorkspaces ( ) ;
78- const { valid, graph } = await project . getDependencyGraph ( workspaces ) ;
79- const expectedDependencies = {
78+ let workspaces = await project . getWorkspaces ( ) ;
79+ let { valid, graph } = await project . getDependencyGraph ( workspaces ) ;
80+ let expectedDependencies = {
8081 'fixture-project-nested-workspaces' : [ ] ,
8182 foo : [ 'bar' ] ,
8283 bar : [ ] ,
@@ -93,9 +94,9 @@ describe('Project', () => {
9394 } ) ;
9495
9596 it ( 'should be able to getDependentsGraph' , async ( ) => {
96- const workspaces = await project . getWorkspaces ( ) ;
97- const { valid, graph } = await project . getDependentsGraph ( workspaces ) ;
98- const expectedDependents = {
97+ let workspaces = await project . getWorkspaces ( ) ;
98+ let { valid, graph } = await project . getDependentsGraph ( workspaces ) ;
99+ let expectedDependents = {
99100 bar : [ 'foo' , 'baz' ] ,
100101 foo : [ ] ,
101102 baz : [ ]
@@ -113,23 +114,20 @@ describe('Project', () => {
113114
114115 describe ( 'A project with nested workspaces and transitive dependents' , ( ) => {
115116 beforeEach ( async ( ) => {
116- const filePath = await getFixturePath (
117- __dirname ,
118- 'nested-workspaces-transitive-dependents'
119- ) ;
117+ let filePath = f . find ( 'nested-workspaces-transitive-dependents' ) ;
120118 project = await Project . init ( filePath ) ;
121119 } ) ;
122120
123121 it ( 'should be able to getWorkspaces (including nested)' , async ( ) => {
124- const workspaces = await project . getWorkspaces ( ) ;
122+ let workspaces = await project . getWorkspaces ( ) ;
125123 expect ( workspaces . length ) . toEqual ( 4 ) ;
126124 expect ( workspaces [ 0 ] ) . toBeInstanceOf ( Workspace ) ;
127125 } ) ;
128126
129127 it ( 'should be able to getDependencyGraph' , async ( ) => {
130- const workspaces = await project . getWorkspaces ( ) ;
131- const { valid, graph } = await project . getDependencyGraph ( workspaces ) ;
132- const expectedDependencies = {
128+ let workspaces = await project . getWorkspaces ( ) ;
129+ let { valid, graph } = await project . getDependencyGraph ( workspaces ) ;
130+ let expectedDependencies = {
133131 'nested-workspaces-transitive-dependents' : [ ] ,
134132 'pkg-a' : [ ] ,
135133 'workspace-a' : [ 'pkg-a' ] ,
@@ -141,8 +139,8 @@ describe('Project', () => {
141139 expect ( graph ) . toBeInstanceOf ( Map ) ;
142140 expect ( graph . size ) . toBe ( Object . keys ( expectedDependencies ) . length ) ;
143141
144- const assertDependencies = ( pkg , deps ) => {
145- const val = graph . get ( pkg ) ;
142+ let assertDependencies = ( pkg , deps ) => {
143+ let val = graph . get ( pkg ) ;
146144 expect ( val && val . dependencies ) . toEqual ( deps ) ;
147145 } ;
148146
@@ -152,9 +150,9 @@ describe('Project', () => {
152150 } ) ;
153151
154152 it ( 'should be able to getDependentsGraph' , async ( ) => {
155- const workspaces = await project . getWorkspaces ( ) ;
156- const { valid, graph } = await project . getDependentsGraph ( workspaces ) ;
157- const expectedDependents = {
153+ let workspaces = await project . getWorkspaces ( ) ;
154+ let { valid, graph } = await project . getDependentsGraph ( workspaces ) ;
155+ let expectedDependents = {
158156 'pkg-a' : [ 'workspace-a' , 'pkg-b' ] ,
159157 'workspace-a' : [ ] ,
160158 'pkg-b' : [ 'pkg-c' ] ,
@@ -177,7 +175,7 @@ describe('Project', () => {
177175 let workspaces ;
178176
179177 beforeEach ( async ( ) => {
180- cwd = await getFixturePath ( __dirname , 'nested-workspaces' ) ;
178+ cwd = f . find ( 'nested-workspaces' ) ;
181179 project = project = await Project . init ( cwd ) ;
182180 workspaces = await project . getWorkspaces ( ) ;
183181 } ) ;
@@ -245,10 +243,7 @@ describe('Project', () => {
245243 } ) ;
246244
247245 it ( 'should support scoped workspaces' , async ( ) => {
248- cwd = await getFixturePath (
249- __dirname ,
250- 'nested-workspaces-with-scoped-package-names'
251- ) ;
246+ cwd = f . find ( 'nested-workspaces-with-scoped-package-names' ) ;
252247 project = project = await Project . init ( cwd ) ;
253248 workspaces = await project . getWorkspaces ( ) ;
254249
@@ -272,7 +267,7 @@ describe('Project', () => {
272267
273268 describe ( 'runWorkspaceTasks()' , ( ) => {
274269 test ( 'independent workspaces' , async ( ) => {
275- let cwd = await getFixturePath ( __dirname , 'independent-workspaces' ) ;
270+ let cwd = f . find ( 'independent-workspaces' ) ;
276271 let project = await Project . init ( cwd ) ;
277272 let workspaces = await project . getWorkspaces ( ) ;
278273 let ops = [ ] ;
@@ -288,7 +283,7 @@ describe('Project', () => {
288283 } ) ;
289284
290285 test ( 'dependent workspaces' , async ( ) => {
291- let cwd = await getFixturePath ( __dirname , 'dependent-workspaces' ) ;
286+ let cwd = f . find ( 'dependent-workspaces' ) ;
292287 let project = await Project . init ( cwd ) ;
293288 let workspaces = await project . getWorkspaces ( ) ;
294289 let ops = [ ] ;
@@ -304,10 +299,7 @@ describe('Project', () => {
304299 } ) ;
305300
306301 test ( 'dependent workspaces with cycle' , async ( ) => {
307- let cwd = await getFixturePath (
308- __dirname ,
309- 'dependent-workspaces-with-cycle'
310- ) ;
302+ let cwd = f . find ( 'dependent-workspaces-with-cycle' ) ;
311303 let project = await Project . init ( cwd ) ;
312304 let workspaces = await project . getWorkspaces ( ) ;
313305 let ops = [ ] ;
0 commit comments