Created
February 3, 2017 03:15
-
-
Save treshugart/d0ddc64f22172f5f68e6b7b8ab471306 to your computer and use it in GitHub Desktop.
I used https://github.com/lelandrichardson/enzyme-example-karma-webpack for a default setup and then put the following in the test file.
This file contains hidden or 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
import React, { Component } from 'react'; | |
import styled from 'styled-components'; | |
import { mount } from 'enzyme'; | |
describe("A suite", function() { | |
it("should select an element using standard and non-standard DOM attributes", function() { | |
const StyledComponent = styled.div` | |
background-color: black; | |
`; | |
class Test extends Component { | |
render () { | |
return ( | |
<div> | |
<StyledComponent value="test" /> | |
<StyledComponent value="test" nonStandard="test" /> | |
</div> | |
); | |
} | |
} | |
expect(mount(<Test />).find({ | |
value: 'test' | |
}).length).toBe(2, 'standard'); | |
expect(mount(<Test />).find({ | |
nonStandard: 'test' | |
}).length).toBe(1, 'non-standard'); | |
expect(mount(<Test />).find({ | |
nonStandard: 'test', | |
value: 'test' | |
}).length).toBe(1, 'mixture'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The purpose of these is to use them in the tagged literal as props, so need non string values to work. Don't have the capacity to try at the moment if that will yield expected results but will have a go on Monday. Thanks again for your response, @mxstbr!