Created
July 19, 2011 01:19
-
-
Save gfredericks/1091100 to your computer and use it in GitHub Desktop.
Five levels of nested functions
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
describe 'VisitCalendarView', -> | |
tr_for = (service_name) -> | |
# This commented version is more direct but jquery seems to bug out on it. | |
# Boo jquery! | |
# $("tr.line-item-view:has(td:first-child:contains(#{service_name}))") | |
$("tr.line-item-view td:first-child:contains(#{service_name})").parent() | |
beforeEach -> | |
ServerMocker.mock_model(ServiceRequest, 'abc123', Fixtures.service_request) | |
ServerMocker.mock_collection ServiceList, Fixtures.deep_services, (model) -> | |
url = if(_.isFunction(model.url)) then model.url() else model.url | |
url == "service_requests/abc123/services" | |
runs -> | |
app.navigate('') | |
app.navigate('service_requests/abc123/visits', true) | |
waits 10 | |
it 'should show a table', -> | |
runs -> | |
expect($(".visit-calendar-view table")).toBeVisible() | |
it 'should list the services in the table', -> | |
runs -> | |
for service in Fixtures.services | |
expect($(".visit-calendar-view td:first-child:contains(#{service.name})")).toBeVisible() | |
it "should show a select drop-down with all subject-counts from 1 to N", -> | |
runs -> | |
for service in Fixtures.services | |
subject_count = tr_for(service.name).find('select.subject_count') | |
expect(subject_count).toExist() | |
options = ($(opt).attr('value') for opt in subject_count.find('option')) | |
num_strings = (('' + n) for n in [1 .. Fixtures.service_request.subject_count]) | |
expect(options.sort()).toEqual(num_strings.sort()) | |
describe "Quantity", -> | |
it "should show the quantity count for a visit", -> | |
runs -> | |
expect($(".visit-calendar-view td span.quantity:first").text()).toEqual("1") | |
it "should increment when I click on it", -> | |
td = null | |
span = -> td.find('.quantity') | |
runs -> | |
td = $(".visit-calendar-view td.visit-view:first") | |
expect(span().text()).toEqual('1') | |
span().click() | |
waits 5 | |
runs -> | |
expect(span().text()).toEqual('2') | |
describe "Arrow Buttons", -> | |
it "should show them", -> | |
runs -> | |
tr_for('EKG') | |
describe "Billing", -> | |
it "should cycle through the four billing options when I click", -> | |
td = null | |
span = -> | |
ret = td.find('.billing') | |
expect(ret).toExist() | |
ret | |
runs -> | |
td = $(".visit-calendar-view td.visit-view:first") | |
expect(td).toBeVisible() | |
expect(span().text()).toEqual('') | |
span().click() | |
waits 5 | |
runs -> | |
expect(span().text()).toEqual('R') | |
span().click() | |
waits 5 | |
runs -> | |
expect(span().text()).toEqual('T') | |
span().click() | |
waits 5 | |
runs -> | |
expect(span().text()).toEqual('%') | |
span().click() | |
waits 5 | |
runs -> | |
expect(span().text()).toEqual('') | |
xdescribe "Subtotals", -> | |
it "should show a blank subtotal if quantity is blank", -> | |
tr = 'foo' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment