added Tester.assertTitleMatch() method
Showing
4 changed files
with
24 additions
and
1 deletions
... | @@ -8,6 +8,7 @@ XXXX-XX-XX, v0.6.11 | ... | @@ -8,6 +8,7 @@ XXXX-XX-XX, v0.6.11 |
8 | - fixes [#140](https://github.com/n1k0/casperjs/issues/140) - `casper test` now resolves local paths urls | 8 | - fixes [#140](https://github.com/n1k0/casperjs/issues/140) - `casper test` now resolves local paths urls |
9 | - closed [#144](https://github.com/n1k0/casperjs/issues/144) - added a `safeLogs` option to blur password values in debug logs. **This option is set to `true` by default.** | 9 | - closed [#144](https://github.com/n1k0/casperjs/issues/144) - added a `safeLogs` option to blur password values in debug logs. **This option is set to `true` by default.** |
10 | - added [`Casper.userAgent()`](http://casperjs.org/api.html#casper.userAgent) to ease a more dynamic setting of user-agent string | 10 | - added [`Casper.userAgent()`](http://casperjs.org/api.html#casper.userAgent) to ease a more dynamic setting of user-agent string |
11 | - added `Tester.assertTitleMatch()` method | ||
11 | - switched to more standard `.textContent` property to get a node text; this allows a better compatibility of the clientutils bookmarklet with non-webkit browsers | 12 | - switched to more standard `.textContent` property to get a node text; this allows a better compatibility of the clientutils bookmarklet with non-webkit browsers |
12 | - casper modules now all use [javascript strict mode](http://www.nczonline.net/blog/2012/03/13/its-time-to-start-using-javascript-strict-mode/) | 13 | - casper modules now all use [javascript strict mode](http://www.nczonline.net/blog/2012/03/13/its-time-to-start-using-javascript-strict-mode/) |
13 | 14 | ... | ... |
... | @@ -390,6 +390,25 @@ var Tester = function Tester(casper, options) { | ... | @@ -390,6 +390,25 @@ var Tester = function Tester(casper, options) { |
390 | }; | 390 | }; |
391 | 391 | ||
392 | /** | 392 | /** |
393 | * Asserts that title of the remote page matched the provided pattern. | ||
394 | * | ||
395 | * @param RegExp pattern The pattern to test the title against | ||
396 | * @param String message Test description | ||
397 | * @return Object An assertion result object | ||
398 | */ | ||
399 | this.assertTitleMatch = this.assertTitleMatches = function assertTitleMatch(pattern, message) { | ||
400 | var currentTitle = casper.getTitle(); | ||
401 | return this.assert(pattern.test(currentTitle), message, { | ||
402 | type: "assertTitle", | ||
403 | details: "Page title does not match the provided pattern", | ||
404 | values: { | ||
405 | subject: currentTitle, | ||
406 | pattern: pattern | ||
407 | } | ||
408 | }); | ||
409 | }; | ||
410 | |||
411 | /** | ||
393 | * Asserts that the provided subject is of the given type. | 412 | * Asserts that the provided subject is of the given type. |
394 | * | 413 | * |
395 | * @param mixed subject The value to test | 414 | * @param mixed subject The value to test | ... | ... |
... | @@ -96,6 +96,9 @@ casper.then(function() { | ... | @@ -96,6 +96,9 @@ casper.then(function() { |
96 | t.comment('Tester.assertTitle()'); | 96 | t.comment('Tester.assertTitle()'); |
97 | t.assertTitle('CasperJS test index', 'Tester.assertTitle() works as expected'); | 97 | t.assertTitle('CasperJS test index', 'Tester.assertTitle() works as expected'); |
98 | 98 | ||
99 | t.comment('Tester.assertTitleMatch()'); | ||
100 | t.assertTitleMatch(/test index/, 'Tester.assertTitleMatch() works as expected'); | ||
101 | |||
99 | t.comment('Tester.assertType()'); | 102 | t.comment('Tester.assertType()'); |
100 | t.assertType("plop", "string", "Tester.assertType() works as expected"); | 103 | t.assertType("plop", "string", "Tester.assertType() works as expected"); |
101 | 104 | ... | ... |
-
Please register or sign in to post a comment