Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support named component imports #475
- Loading branch information
Showing
5 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
packages/react-cosmos-voyager2/src/server/__tests__/esm/single-named/__fsmocks__/Italic.js
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,7 @@ | ||
// @flow | ||
|
||
import React from 'react'; | ||
|
||
export const CONST = 'foo'; | ||
|
||
export const Italic = ({ name }: { name: string }) => <em>{name}</em>; |
8 changes: 8 additions & 0 deletions
8
packages/react-cosmos-voyager2/src/server/__tests__/esm/single-named/__fsmocks__/fixture.js
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,8 @@ | ||
// @flow | ||
|
||
import { Italic } from './Italic'; | ||
|
||
export default { | ||
component: Italic, | ||
props: {} | ||
}; |
8 changes: 8 additions & 0 deletions
8
...osmos-voyager2/src/server/__tests__/esm/single-named/__fsmocks__/multi-imports.fixture.js
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,8 @@ | ||
// @flow | ||
|
||
import { CONST, Italic } from './Italic'; | ||
|
||
export default { | ||
component: Italic, | ||
props: {} | ||
}; |
50 changes: 50 additions & 0 deletions
50
packages/react-cosmos-voyager2/src/server/__tests__/esm/single-named/index.js
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,50 @@ | ||
// @flow | ||
|
||
import { join } from 'path'; | ||
import { findFixtureFiles } from '../../../find-fixture-files'; | ||
|
||
const { resolve } = require; | ||
|
||
describe('ES module / Single fixture with named component import', () => { | ||
let files; | ||
|
||
beforeEach(async () => { | ||
files = await findFixtureFiles({ | ||
rootPath: join(__dirname, '__fsmocks__') | ||
}); | ||
}); | ||
|
||
describe('single named import', () => { | ||
it('has fixture path', () => { | ||
expect(files[0].filePath).toBe(resolve('./__fsmocks__/fixture')); | ||
}); | ||
|
||
it('has component name', () => { | ||
expect(files[0].components[0].name).toBe('Italic'); | ||
}); | ||
|
||
it('has component path', () => { | ||
expect(files[0].components[0].filePath).toBe( | ||
resolve('./__fsmocks__/Italic') | ||
); | ||
}); | ||
}); | ||
|
||
describe('multi named imports', () => { | ||
it('has fixture path', () => { | ||
expect(files[1].filePath).toBe( | ||
resolve('./__fsmocks__/multi-imports.fixture') | ||
); | ||
}); | ||
|
||
it('has component name', () => { | ||
expect(files[1].components[0].name).toBe('Italic'); | ||
}); | ||
|
||
it('has component path', () => { | ||
expect(files[1].components[0].filePath).toBe( | ||
resolve('./__fsmocks__/Italic') | ||
); | ||
}); | ||
}); | ||
}); |
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