Open DinisCruz opened 8 years ago
here is an example of accessing this via jsdom
it 'check page contents', ()->
using jsDom, ->
table_Headers = (@.$(th).html() for th in @.$('table th'))
table_Headers.size().assert_Is 20
table_Headers.assert_Contains ['ID', 'Yes', 'No', 'NA','Maybe']
all_Rows = @.$('table tr')
all_Cells = @.$('table td')
all_Rows.length.assert_Is 120
all_Cells.length.assert_Is 560
@.$('#save-data').html().assert_Is 'save' # save button
@.$('#team-name').val() .assert_Is 'Team A' # team name input fie
@.$('#message' ).html().assert_Is 'data loaded' # status message
@.$('#domain' ).text().assert_Is 'Governance' # save button
using @.$('tr[id="SM.1.1"] td'),->
@.length.assert_Is 5
@.eq(0).html().assert_Is 'SM.1.1'
@.eq(1).html().assert_Is '<input type="radio" ng-name="key" ng-model="data[key]" value="Yes" class="ng-pristine ng-untouched ng-valid ng-not-empty" name="26">'
@.eq(1).find('input').val().assert_Is 'Yes'
@.eq(2).find('input').val().assert_Is 'No'
@.eq(3).find('input').val().assert_Is 'NA'
@.eq(4).find('input').val().assert_Is 'Maybe'
here is how to trigger a click in JsDom
it 'Check save message', (done)->
using jsDom, ->
@.$('#message').html().assert_Is 'data loaded' # message before save
@.window.angular.element(@.$('#save-data')).triggerHandler('click') # this is what triggers the .click() event
@.wait_No_Http_Requests => # wait for http requests
@.$('#message' ).html().assert_Is 'file saved ok' # message after save
done()