This repository was archived by the owner on Aug 17, 2018. It is now read-only.
File tree 6 files changed +24
-67
lines changed
6 files changed +24
-67
lines changed Original file line number Diff line number Diff line change @@ -41,24 +41,12 @@ describe('Named multi fixture file', () => {
41
41
) ;
42
42
} ) ;
43
43
44
- it ( 'has source' , ( ) => {
45
- expect ( fixtures [ 0 ] . source ) . toEqual ( {
46
- name : 'A fix' ,
47
- component : Bold ,
48
- props : {
49
- name : 'Alina'
50
- }
51
- } ) ;
44
+ it ( 'has fixtureIndex 0' , ( ) => {
45
+ expect ( fixtures [ 0 ] . fixtureIndex ) . toBe ( 0 ) ;
52
46
} ) ;
53
47
54
- it ( 'has source' , ( ) => {
55
- expect ( fixtures [ 1 ] . source ) . toEqual ( {
56
- name : 'S fix' ,
57
- component : Bold ,
58
- props : {
59
- name : 'Sarah'
60
- }
61
- } ) ;
48
+ it ( 'has fixtureIndex 1' , ( ) => {
49
+ expect ( fixtures [ 1 ] . fixtureIndex ) . toBe ( 1 ) ;
62
50
} ) ;
63
51
} ) ;
64
52
@@ -79,14 +67,8 @@ describe('Named multi fixture file', () => {
79
67
) ;
80
68
} ) ;
81
69
82
- it ( 'has source' , ( ) => {
83
- expect ( fixtures [ 0 ] . source ) . toEqual ( {
84
- name : 'J fix' ,
85
- component : Italics ,
86
- props : {
87
- name : 'John'
88
- }
89
- } ) ;
70
+ it ( 'has fixtureIndex 2' , ( ) => {
71
+ expect ( fixtures [ 0 ] . fixtureIndex ) . toBe ( 2 ) ;
90
72
} ) ;
91
73
} ) ;
92
74
} ) ;
Original file line number Diff line number Diff line change @@ -41,22 +41,12 @@ describe('Unnamed multi fixture file', () => {
41
41
) ;
42
42
} ) ;
43
43
44
- it ( 'has source' , ( ) => {
45
- expect ( fixtures [ 0 ] . source ) . toEqual ( {
46
- component : Bold ,
47
- props : {
48
- name : 'Alina'
49
- }
50
- } ) ;
44
+ it ( 'has fixtureIndex 0' , ( ) => {
45
+ expect ( fixtures [ 0 ] . fixtureIndex ) . toBe ( 0 ) ;
51
46
} ) ;
52
47
53
- it ( 'has source' , ( ) => {
54
- expect ( fixtures [ 1 ] . source ) . toEqual ( {
55
- component : Bold ,
56
- props : {
57
- name : 'Sarah'
58
- }
59
- } ) ;
48
+ it ( 'has fixtureIndex 1' , ( ) => {
49
+ expect ( fixtures [ 1 ] . fixtureIndex ) . toBe ( 1 ) ;
60
50
} ) ;
61
51
} ) ;
62
52
@@ -77,13 +67,8 @@ describe('Unnamed multi fixture file', () => {
77
67
) ;
78
68
} ) ;
79
69
80
- it ( 'has source' , ( ) => {
81
- expect ( fixtures [ 0 ] . source ) . toEqual ( {
82
- component : Italics ,
83
- props : {
84
- name : 'John'
85
- }
86
- } ) ;
70
+ it ( 'has fixtureIndex 2' , ( ) => {
71
+ expect ( fixtures [ 0 ] . fixtureIndex ) . toBe ( 2 ) ;
87
72
} ) ;
88
73
} ) ;
89
74
} ) ;
Original file line number Diff line number Diff line change @@ -23,13 +23,7 @@ describe('Named single fixture file', () => {
23
23
) ;
24
24
} ) ;
25
25
26
- it ( 'has fixture source' , ( ) => {
27
- expect ( components [ 0 ] . fixtures [ 0 ] . source ) . toEqual ( {
28
- component : Italics ,
29
- name : 'foo fixture' ,
30
- props : {
31
- name : 'John'
32
- }
33
- } ) ;
26
+ it ( 'has null fixtureIndex' , ( ) => {
27
+ expect ( components [ 0 ] . fixtures [ 0 ] . fixtureIndex ) . toBe ( null ) ;
34
28
} ) ;
35
29
} ) ;
Original file line number Diff line number Diff line change @@ -23,12 +23,7 @@ describe('Unnamed single fixture file', () => {
23
23
) ;
24
24
} ) ;
25
25
26
- it ( 'has fixture source' , ( ) => {
27
- expect ( components [ 0 ] . fixtures [ 0 ] . source ) . toEqual ( {
28
- component : Italics ,
29
- props : {
30
- name : 'John'
31
- }
32
- } ) ;
26
+ it ( 'has null fixtureIndex' , ( ) => {
27
+ expect ( components [ 0 ] . fixtures [ 0 ] . fixtureIndex ) . toBe ( null ) ;
33
28
} ) ;
34
29
} ) ;
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ export async function getComponents(args: Args): Promise<Components> {
62
62
// Can't use forEach because we want each (async) loop to be serial
63
63
for ( let j = 0 ; j < fixturesInFile . length ; j ++ ) {
64
64
const fixture = fixturesInFile [ j ] ;
65
+ const fixtureIndex = isMultiFixture ? j : null ;
65
66
const { component, name } = fixture ;
66
67
67
68
// TODO: Throw if fixture.component is missing
@@ -79,9 +80,9 @@ export async function getComponents(args: Args): Promise<Components> {
79
80
80
81
compFixtures . push ( {
81
82
filePath : fixturePath ,
83
+ fixtureIndex,
82
84
name : name || defaultFixtureNamer ( component ) ,
83
- namespace,
84
- source : fixture
85
+ namespace
85
86
} ) ;
86
87
87
88
if ( ! componentPaths . get ( component ) ) {
@@ -90,7 +91,7 @@ export async function getComponents(args: Args): Promise<Components> {
90
91
componentPath
91
92
} = await getComponentInfoFromFixture ( {
92
93
fixturePath,
93
- fixtureIndex : isMultiFixture ? j : null
94
+ fixtureIndex
94
95
} ) ;
95
96
96
97
// It's possible to identify the component name but not the file path
Original file line number Diff line number Diff line change 3
3
import type { ComponentType } from 'react' ;
4
4
5
5
export type Fixture = {
6
- name : string ,
7
- namespace : string ,
8
6
filePath : string ,
9
- source : Object
7
+ fixtureIndex : number | null ,
8
+ name : string ,
9
+ namespace : string
10
10
} ;
11
11
12
12
export type Fixtures = Array < Fixture > ;
13
13
14
14
export type FixturesByComponent = Map < ComponentType < * > , Fixtures > ;
15
15
16
16
export type Component = {
17
+ filePath : string | null ,
17
18
name : string ,
18
19
namespace : string ,
19
- filePath : string | null ,
20
20
type : ComponentType < * > ,
21
21
fixtures : Fixtures
22
22
} ;
You can’t perform that action at this time.
0 commit comments