specs for deleting a file/folder
closes: CNVS-14726 we need to figure out how to load react-with-addons.js when we are running specs but just react.js outside of tests Change-Id: I7fb2b0be73a0b9be5266c0a5d9a720dfba0146f9 Reviewed-on: https://gerrit.instructure.com/39187 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jason Madsen <jmadsen@instructure.com> Product-Review: Ryan Shaw <ryan@instructure.com> QA-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
parent
aa5eff4d13
commit
d4fc0cce7e
|
@ -59,7 +59,7 @@ define [
|
|||
li {},
|
||||
a onClick: @openRestrictedDialog, href:'#', id:'content-3', tabIndex:'-1', role:'menuitem', title:'Restrict Access', 'Restrict Access'
|
||||
li {},
|
||||
a onClick: @deleteItem, href:'#', id:'content-3', tabIndex:'-1', role:'menuitem', title:'Delete', 'Delete'
|
||||
a ref: 'deleteLink', onClick: @deleteItem, href:'#', id:'content-3', tabIndex:'-1', role:'menuitem', title:'Delete', 'Delete'
|
||||
|
||||
(li {},
|
||||
a href:'#', id:'content-3', tabIndex:'-1', role:'menuitem', title:'Download as Zip',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
define(['bower/react/react'], function(React) {
|
||||
define(['bower/react/react-with-addons'], function(React) {
|
||||
window.React = window.React || React;
|
||||
return React;
|
||||
});
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
define [
|
||||
'react'
|
||||
'jquery'
|
||||
'compiled/react_files/components/ItemCog'
|
||||
'compiled/models/Folder'
|
||||
], (React, $, ItemCog, Folder) ->
|
||||
|
||||
Simulate = React.addons.TestUtils.Simulate
|
||||
|
||||
module 'ItemCog',
|
||||
setup: ->
|
||||
|
||||
sampleProps =
|
||||
model: new Folder(id: 999)
|
||||
startEditingName: -> debugger
|
||||
|
||||
@itemCog = React.renderComponent(ItemCog(sampleProps), $('<div>').appendTo('body')[0])
|
||||
|
||||
teardown: ->
|
||||
React.unmountComponentAtNode(@itemCog.getDOMNode().parentNode)
|
||||
|
||||
|
||||
test 'deletes model when delete link is pressed', ->
|
||||
sinon.stub($, 'ajax')
|
||||
sinon.stub(window, 'confirm').returns(true)
|
||||
|
||||
Simulate.click(@itemCog.refs.deleteLink.getDOMNode())
|
||||
|
||||
ok window.confirm.calledOnce, 'confirms before deleting'
|
||||
ok $.ajax.calledWithMatch({url: '/api/v1/folders/999', type: 'DELETE'}), 'sends DELETE to right url'
|
||||
|
||||
window.confirm.restore()
|
||||
$.ajax.restore()
|
Loading…
Reference in New Issue