blob: 8eebb3eead1f6fc528bcb10721582b7a4cf233f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
import React from 'react';
import {shallow} from 'enzyme';
import chaiEnzyme from 'chai-enzyme'
import sinon from 'sinon'
import chai, { expect } from 'chai'
import Confirmation from '../../app/components/confirmation';
describe('Confirmation Component', () => {
it('Passed functionss run on click', () => {
const onAcceptFuncTest = sinon.spy();
const onCancelFuncTest = sinon.spy();
const confirmation = shallow(
<Confirmation
onAccept={onAcceptFuncTest}
onCancel={onCancelFuncTest}
/>
)
confirmation.find('Button').at(0).simulate('click')
expect(onAcceptFuncTest.calledOnce).to.equal(true)
confirmation.find('Button').at(1).simulate('click')
expect(onCancelFuncTest.calledOnce).to.equal(true)
})
it('sets defaults correctly', () => {
const confirmation = shallow(
<Confirmation
onAccept={() => {}}
onCancel={() => {}}
/>
)
expect(confirmation.find("ModalTitle").first().children()).to.have.text("Are you sure?")
expect(confirmation.find('Button').at(0).children().first()).to.have.text("Accept")
expect(confirmation.find('Button').at(1).children().first()).to.have.text("Cancel")
})
it('overwrites defaults correctly', () => {
const onAcceptFuncTest = () => {}
const onCancelFuncTest = () => {}
const testTitle = "Test Title"
const testAcceptStr = "Test accept string"
const testCancelStr = "Test cancel string"
const confirmation = shallow(
<Confirmation
onAccept={() => {}}
onCancel={() => {}}
title={testTitle}
acceptStr={testAcceptStr}
cancelStr={testCancelStr}
/>
)
expect(confirmation.find("ModalTitle").first().children()).to.have.text(testTitle)
expect(confirmation.find('Button').at(0).children().first()).to.have.text(testAcceptStr)
expect(confirmation.find('Button').at(1).children().first()).to.have.text(testCancelStr)
})
})
|