Last active
December 25, 2015 07:29
-
-
Save vojtajina/6939241 to your computer and use it in GitHub Desktop.
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
// DSL - these migt be provided by protractor | |
// `protractor` is globally provided instance of Provider (connected webdriver instance) | |
// `protractor.driver` can be the wrapper webdriver instance | |
var navigateTo = protractor.get; | |
var element = protractor.getElementByCssSelector; | |
var button = function(label) { | |
return protractor.getElementByCssSelector(':button:contains("' + label + '")'); | |
}; | |
// We should provide some syntactic sugar for defining custom helpers. | |
// This is an example of how that could look. | |
// This defines the `button` helper again, just using the syntactic sugar. | |
var button = protractor.getElementByCssSelector.bind(':button:contains("%1")'); | |
// HERE IS THE SPEC | |
describe('$http', function() { | |
beforeEach(function() { | |
navigateTo('index-jq-nocache.html#!/api/ng.$http'); | |
}); | |
it('should make a JSONP request to angularjs.org', function() { | |
button('Sample JSONP').click(); | |
button('fetch').click(); | |
// When I have more tests, I would wrap these into some project specific helpers, | |
// so that I can easily share them between tests. | |
expect(element('{{status}}').text()).toBe('200'); | |
expect(element('{{data}}').text()).toMatch(/Super Hero!/); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment