@@ -13,73 +13,73 @@ const template: (props: ComponentProps) => ReturnType<typeof html> = ({ size, va
13
13
` ;
14
14
15
15
describe ( 'createStory' , ( ) => {
16
- it ( 'should create a story with default args' , ( ) => {
17
- const defaultArgs : ComponentProps = { size : 'medium' , variant : 'primary' } ;
18
- const story = createStory ( template , defaultArgs ) ;
19
-
20
- const result = story ( ) ;
21
- expect ( result . args ) . toEqual ( defaultArgs ) ;
22
- expect ( result . render ( defaultArgs ) ) . toHaveProperty ( 'strings' ) ;
23
- } ) ;
24
-
25
- it ( 'should override default args with prop overrides' , ( ) => {
26
- const defaultArgs : ComponentProps = { size : 'medium' , variant : 'primary' } ;
27
- const story = createStory ( template , defaultArgs ) ;
28
-
29
- const propOverrides = { variant : 'secondary' } ;
30
- const result = story ( propOverrides ) ;
31
- expect ( result . args ) . toEqual ( { size : 'medium' , variant : 'secondary' } ) ;
32
- } ) ;
33
-
34
- it ( 'should apply story options correctly' , ( ) => {
35
- const defaultArgs : ComponentProps = { size : 'medium' , variant : 'primary' } ;
36
- const storyOpts : StoryOptions = {
37
- bgColor : 'background-subtle' ,
38
- } ;
39
- const story = createStory ( template , defaultArgs ) ;
40
-
41
- const result = story ( { } , storyOpts ) ;
42
- expect ( result . parameters . backgrounds . default ) . toBe ( 'background-subtle' ) ;
43
- } ) ;
16
+ it ( 'should create a story with default args' , ( ) => {
17
+ const defaultArgs : ComponentProps = { size : 'medium' , variant : 'primary' } ;
18
+ const story = createStory ( template , defaultArgs ) ;
19
+
20
+ const result = story ( ) ;
21
+ expect ( result . args ) . toEqual ( defaultArgs ) ;
22
+ expect ( result . render ( defaultArgs ) ) . toHaveProperty ( 'strings' ) ;
23
+ } ) ;
24
+
25
+ it ( 'should override default args with prop overrides' , ( ) => {
26
+ const defaultArgs : ComponentProps = { size : 'medium' , variant : 'primary' } ;
27
+ const story = createStory ( template , defaultArgs ) ;
28
+
29
+ const propOverrides = { variant : 'secondary' } ;
30
+ const result = story ( propOverrides ) ;
31
+ expect ( result . args ) . toEqual ( { size : 'medium' , variant : 'secondary' } ) ;
32
+ } ) ;
33
+
34
+ it ( 'should apply story options correctly' , ( ) => {
35
+ const defaultArgs : ComponentProps = { size : 'medium' , variant : 'primary' } ;
36
+ const storyOpts : StoryOptions = {
37
+ bgColor : 'background-subtle' ,
38
+ } ;
39
+ const story = createStory ( template , defaultArgs ) ;
40
+
41
+ const result = story ( { } , storyOpts ) ;
42
+ expect ( result . parameters . backgrounds . default ) . toBe ( 'background-subtle' ) ;
43
+ } ) ;
44
44
} ) ;
45
45
46
46
describe ( 'createVariantStory' , ( ) => {
47
- it ( 'should generate all combinations of prop options' , ( ) => {
48
- const propOptions = {
49
- size : [ 'small' , 'medium' , 'large' ] ,
50
- variant : [ 'primary' , 'secondary' ] ,
51
- } ;
52
-
53
- const story = createVariantStory ( template , propOptions ) ;
54
- const renderResult = story . render ( ) ;
55
-
56
- // Render the template to a DOM element
57
- const container = document . createElement ( 'div' ) ;
58
- render ( renderResult , container ) ;
59
-
60
- // Count the number of pie-component elements
61
- const renderedCombinations = container . querySelectorAll ( 'pie-component' ) ;
62
- const expectedCombinationsCount = propOptions . size . length * propOptions . variant . length ;
63
- expect ( renderedCombinations . length ) . toBe ( expectedCombinationsCount ) ;
64
- } ) ;
65
-
66
- it ( 'should apply story options correctly' , ( ) => {
67
- const propOptions = {
68
- size : [ 'small' ] ,
69
- variant : [ 'primary' ] ,
70
- } ;
71
-
72
- const storyOpts : StoryOptions = {
73
- bgColor : 'background-subtle' ,
74
- argTypes : { size : { control : 'text' } } ,
75
- } ;
76
-
77
- const story = createVariantStory ( template , propOptions , storyOpts ) ;
78
-
79
- // Check if the parameters include the background color
80
- expect ( story . parameters . backgrounds . default ) . toBe ( 'background-subtle' ) ;
81
-
82
- // Check if argTypes are applied
83
- expect ( story . argTypes ) . toEqual ( storyOpts . argTypes ) ;
84
- } ) ;
85
- } ) ;
47
+ it ( 'should generate all combinations of prop options' , ( ) => {
48
+ const propOptions = {
49
+ size : [ 'small' , 'medium' , 'large' ] ,
50
+ variant : [ 'primary' , 'secondary' ] ,
51
+ } ;
52
+
53
+ const story = createVariantStory ( template , propOptions ) ;
54
+ const renderResult = story . render ( ) ;
55
+
56
+ // Render the template to a DOM element
57
+ const container = document . createElement ( 'div' ) ;
58
+ render ( renderResult , container ) ;
59
+
60
+ // Count the number of pie-component elements
61
+ const renderedCombinations = container . querySelectorAll ( 'pie-component' ) ;
62
+ const expectedCombinationsCount = propOptions . size . length * propOptions . variant . length ;
63
+ expect ( renderedCombinations . length ) . toBe ( expectedCombinationsCount ) ;
64
+ } ) ;
65
+
66
+ it ( 'should apply story options correctly' , ( ) => {
67
+ const propOptions = {
68
+ size : [ 'small' ] ,
69
+ variant : [ 'primary' ] ,
70
+ } ;
71
+
72
+ const storyOpts : StoryOptions = {
73
+ bgColor : 'background-subtle' ,
74
+ argTypes : { size : { control : 'text' } } ,
75
+ } ;
76
+
77
+ const story = createVariantStory ( template , propOptions , storyOpts ) ;
78
+
79
+ // Check if the parameters include the background color
80
+ expect ( story . parameters . backgrounds . default ) . toBe ( 'background-subtle' ) ;
81
+
82
+ // Check if argTypes are applied
83
+ expect ( story . argTypes ) . toEqual ( storyOpts . argTypes ) ;
84
+ } ) ;
85
+ } ) ;
0 commit comments