@@ -2,6 +2,7 @@ import React from 'react';
22import { create } from 'react-test-renderer' ;
33
44import { Toast } from 'src/Toast' ;
5+ import { Alert } from 'src/Alert' ;
56
67describe ( 'Toast' , ( ) => {
78 test ( 'no header classes' , ( ) => {
@@ -17,4 +18,34 @@ describe('Toast', () => {
1718 expect ( props . className ) . toContain ( 'Toast' ) ;
1819 expect ( props . className ) . toContain ( 'Toast--no-header' ) ;
1920 } ) ;
21+
22+ describe ( 'when building alert props' , ( ) => {
23+ const setup = ( props ) => create (
24+ < Toast
25+ messages = { [
26+ { id : '1' , type : 'success' , ...props } ,
27+ ] }
28+ /> ,
29+ ) ;
30+
31+ test ( 'builds props from string message' , ( ) => {
32+ const { root } = setup ( { message : 'hello' } ) ;
33+
34+ expect ( root . findByType ( Alert ) . props . message ) . toBe ( 'hello' ) ;
35+ } ) ;
36+
37+ test ( 'builds props from node message' , ( ) => {
38+ const { root } = setup ( { message : < div > hello</ div > } ) ;
39+
40+ expect ( root . findByType ( Alert ) . props . message ) . toEqual ( < div > hello</ div > ) ;
41+ } ) ;
42+
43+ describe ( 'when title prop is passed' , ( ) => {
44+ test ( 'builds title prop' , ( ) => {
45+ const { root } = setup ( { title : 'woohoo' , message : 'you did it!' } ) ;
46+
47+ expect ( root . findByType ( Alert ) . props . title ) . toBe ( 'woohoo' ) ;
48+ } ) ;
49+ } ) ;
50+ } ) ;
2051} ) ;
0 commit comments