1
1
import * as React from 'react' ;
2
- import { assert } from 'chai' ;
3
- import { createMount , createShallow , getClasses } from '@material-ui/core/test-utils' ;
2
+ import { expect } from 'chai' ;
3
+ import { createMount , getClasses } from '@material-ui/core/test-utils' ;
4
+ import { createClientRender } from 'test/utils/createClientRender' ;
4
5
import describeConformance from '../test-utils/describeConformance' ;
5
6
import AppBar from './AppBar' ;
6
7
import Paper from '../Paper' ;
7
8
8
9
describe ( '<AppBar />' , ( ) => {
9
10
let mount ;
10
- let shallow ;
11
11
let classes ;
12
-
12
+ const render = createClientRender ( ) ;
13
13
before ( ( ) => {
14
14
mount = createMount ( { strict : true } ) ;
15
- shallow = createShallow ( { dive : true } ) ;
16
15
classes = getClasses ( < AppBar > Hello World</ AppBar > ) ;
17
16
} ) ;
18
17
@@ -29,30 +28,34 @@ describe('<AppBar />', () => {
29
28
} ) ) ;
30
29
31
30
it ( 'should render with the root class and primary' , ( ) => {
32
- const wrapper = shallow ( < AppBar > Hello World</ AppBar > ) ;
33
- assert . strictEqual ( wrapper . hasClass ( classes . root ) , true ) ;
34
- assert . strictEqual ( wrapper . hasClass ( classes . colorPrimary ) , true ) ;
35
- assert . strictEqual ( wrapper . hasClass ( classes . colorSecondary ) , false ) ;
31
+ const { container } = render ( < AppBar > Hello World</ AppBar > ) ;
32
+ const appBar = container . firstChild ;
33
+ expect ( appBar ) . to . have . class ( classes . root ) ;
34
+ expect ( appBar ) . to . have . class ( classes . colorPrimary ) ;
35
+ expect ( appBar ) . to . not . have . class ( classes . colorSecondary ) ;
36
36
} ) ;
37
37
38
38
it ( 'should render a primary app bar' , ( ) => {
39
- const wrapper = shallow ( < AppBar color = "primary" > Hello World</ AppBar > ) ;
40
- assert . strictEqual ( wrapper . hasClass ( classes . root ) , true ) ;
41
- assert . strictEqual ( wrapper . hasClass ( classes . colorPrimary ) , true ) ;
42
- assert . strictEqual ( wrapper . hasClass ( classes . colorSecondary ) , false ) ;
39
+ const { container } = render ( < AppBar color = "primary" > Hello World</ AppBar > ) ;
40
+ const appBar = container . firstChild ;
41
+ expect ( appBar ) . to . have . class ( classes . root ) ;
42
+ expect ( appBar ) . to . have . class ( classes . colorPrimary ) ;
43
+ expect ( appBar ) . to . not . have . class ( classes . colorSecondary ) ;
43
44
} ) ;
44
45
45
46
it ( 'should render an secondary app bar' , ( ) => {
46
- const wrapper = shallow ( < AppBar color = "secondary" > Hello World</ AppBar > ) ;
47
- assert . strictEqual ( wrapper . hasClass ( classes . root ) , true ) ;
48
- assert . strictEqual ( wrapper . hasClass ( classes . colorPrimary ) , false ) ;
49
- assert . strictEqual ( wrapper . hasClass ( classes . colorSecondary ) , true ) ;
47
+ const { container } = render ( < AppBar color = "secondary" > Hello World</ AppBar > ) ;
48
+ const appBar = container . firstChild ;
49
+ expect ( appBar ) . to . have . class ( classes . root ) ;
50
+ expect ( appBar ) . to . not . have . class ( classes . colorPrimary ) ;
51
+ expect ( appBar ) . to . have . class ( classes . colorSecondary ) ;
50
52
} ) ;
51
53
52
54
describe ( 'Dialog' , ( ) => {
53
55
it ( 'should add a .mui-fixed class' , ( ) => {
54
- const wrapper = shallow ( < AppBar position = "fixed" > Hello World</ AppBar > ) ;
55
- assert . strictEqual ( wrapper . hasClass ( 'mui-fixed' ) , true ) ;
56
+ const { container } = render ( < AppBar position = "fixed" > Hello World</ AppBar > ) ;
57
+ const appBar = container . firstChild ;
58
+ expect ( appBar ) . to . have . class ( 'mui-fixed' ) ;
56
59
} ) ;
57
60
} ) ;
58
61
} ) ;
0 commit comments