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

Commit

Permalink
Add test case for issue yarnpkg#5816
Browse files Browse the repository at this point in the history
  • Loading branch information
Y0hy0h committed May 15, 2018
1 parent d28f8e5 commit f72f5a1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
18 changes: 15 additions & 3 deletions __tests__/commands/workspaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const fixturesLoc = path.join(__dirname, '..', 'fixtures', 'workspace');
async function runWorkspaces(
flags: Object,
args: Array<string>,
name: string,
cwdSubfolders: string[],
checkSteps?: ?(config: Config, reporter: BufferReporter) => ?Promise<void>,
): Promise<void> {
const cwd = path.join(fixturesLoc, name);
const cwd = path.join(fixturesLoc, ...cwdSubfolders);
const reporter = new reporters.BufferReporter({stdout: null, stdin: null, isSilent: true});

const config = await Config.create({cwd}, reporter);
Expand All @@ -27,7 +27,7 @@ async function runWorkspaces(
}

test('workspaces info should list the workspaces', (): Promise<void> => {
return runWorkspaces({}, ['info'], 'run-basic', (config, reporter) => {
return runWorkspaces({}, ['info'], ['run-basic'], (config, reporter) => {
expect(reporter.getBufferJson()).toEqual({
'workspace-1': {
location: 'packages/workspace-child-1',
Expand All @@ -42,3 +42,15 @@ test('workspaces info should list the workspaces', (): Promise<void> => {
});
});
});

test('workspaces info should list the workspaces inside workspace folder', (): Promise<void> => {
return runWorkspaces({}, ['info'], ['run-variations', 'trailing-slash'], (config, reporter) => {
expect(reporter.getBufferJson()).toEqual({
'trailing-slash': {
location: 'trailing-slash',
workspaceDependencies: [],
mismatchedWorkspaceDependencies: [],
},
});
});
});
7 changes: 7 additions & 0 deletions __tests__/fixtures/workspace/run-variations/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "my-project",
"private": true,
"workspaces": [
"trailing-slash/"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "trailing-slash",
"version": "1.0.0",
"license": "UNLICENSED",
"scripts": {
"prescript": "echo trailing-slash prescript",
"script": "echo trailing-slash script",
"postscript": "echo trailing-slash postscript"
}
}

0 comments on commit f72f5a1

Please sign in to comment.