-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* moves the auto_link test data into a JSON file * adds a PHP auto_link test usin the same JSON test data
- Loading branch information
Showing
6 changed files
with
65 additions
and
46 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var test = require('tape'); | ||
|
||
var auto_link = require('../cassis').auto_link; | ||
|
||
var tests = require('../test-data/auto_link.json'); | ||
|
||
test('tests', function (t) { | ||
t.plan(tests.length) | ||
tests.forEach(function (obj) { | ||
t.equal(auto_link(obj.str), obj.expect, obj.msg) | ||
}); | ||
}); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
class AutoLinkTest extends PHPUnit_Framework_TestCase { | ||
|
||
/** | ||
* @dataProvider linkProvider | ||
*/ | ||
public function testAutoLink($expected, $input) { | ||
$this->assertEquals($expected, auto_link($input)); | ||
} | ||
|
||
public function linkProvider() { | ||
$tests = json_decode(file_get_contents(dirname(__FILE__).'/../test-data/auto_link.json')); | ||
return array_map(function($test){ | ||
return [$test->expect, $test->str]; | ||
}, $tests); | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ | ||
{ | ||
"str":"This string definately does not have any urls in it", | ||
"expect":"This string definately does not have any urls in it", | ||
"msg":"noop on strings without links" | ||
}, | ||
{ | ||
"str":"this string definitely has a link to tantek.com in it", | ||
"expect":"this string definitely has a link to <a class=\"auto-link\" href=\"http://tantek.com\">tantek.com</a> in it", | ||
"msg":"auto_link simple .com links" | ||
}, | ||
{ | ||
"str":"This has a stanford.edu link", | ||
"expect":"This has a <a class=\"auto-link\" href=\"http://stanford.edu\">stanford.edu</a> link", | ||
"msg":"auto_link simple .edu links" | ||
}, | ||
{ | ||
"str":"This has a bret.io link", | ||
"expect":"This has a <a class=\"auto-link\" href=\"http://bret.io\">bret.io</a> link", | ||
"msg":"auto_link simple .io links" | ||
} | ||
] |
This file was deleted.
Oops, something went wrong.