Skip to content

Commit

Permalink
fix tests broken by #39
Browse files Browse the repository at this point in the history
  • Loading branch information
stancl committed Nov 22, 2024
1 parent f4ec8c0 commit c768bb7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ To add more tags to the document head, you can use the `tag()` and `rawTag()` me

```php
seo()->tag('fb:image', asset('foo'));
seo()->rawTag('<meta property="fb:url" content="bar" />');
seo()->rawTag('fb_url', '<meta property="fb:url" content="bar" />'); // Keyed, allows overrides later on
seo()->rawTag('<meta property="fb:url" content="bar">');
seo()->rawTag('fb_url', '<meta property="fb:url" content="bar">'); // Keyed, allows overrides later on
```

### Canonical URL
Expand Down
10 changes: 5 additions & 5 deletions resources/views/components/extensions/twitter.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<meta name="twitter:card" content="summary_large_image">
@if(seo('twitter.creator')) <meta name="twitter:creator" content="@seo('twitter.creator')" /> @endif
@if(seo('twitter.site')) <meta name="twitter:site" content="@seo('twitter.site')" /> @endif
@if(seo('twitter.title')) <meta name="twitter:title" content="@seo('twitter.title')" /> @endif
@if(seo('twitter.description')) <meta name="twitter:description" content="@seo('twitter.description')" /> @endif
@if(seo('twitter.image')) <meta name="twitter:image" content="@seo('twitter.image')" /> @endif
@if(seo('twitter.creator')) <meta name="twitter:creator" content="@seo('twitter.creator')"> @endif
@if(seo('twitter.site')) <meta name="twitter:site" content="@seo('twitter.site')"> @endif
@if(seo('twitter.title')) <meta name="twitter:title" content="@seo('twitter.title')"> @endif
@if(seo('twitter.description')) <meta name="twitter:description" content="@seo('twitter.description')"> @endif
@if(seo('twitter.image')) <meta name="twitter:image" content="@seo('twitter.image')"> @endif
2 changes: 1 addition & 1 deletion src/SEOManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public function tag(string $property, string $content): static
{
$content = e($content);

$this->rawTag("meta.{$property}", "<meta property=\"{$property}\" content=\"{$content}\" />");
$this->rawTag("meta.{$property}", "<meta property=\"{$property}\" content=\"{$content}\">");

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Pest/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

seo()->facebookTitle('abc');

expect(meta())->toContain('<meta name="facebook:title" content="ABC" />');
expect(meta())->toContain('<meta name="facebook:title" content="ABC">');
});

test('twitter falls back to the default values', function () {
Expand All @@ -56,7 +56,7 @@
expect(seo('twitter.description'))->toBe('bar');
expect(seo('description'))->toBe('baz');

expect(meta())->toContain('<meta name="twitter:title" content="foo" />');
expect(meta())->toContain('<meta name="twitter:title" content="foo">');
});

test('extensions are automatically enabled when values for them are set', function () {
Expand Down
18 changes: 9 additions & 9 deletions tests/Pest/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
test('meta tags can be added to the template', function () {
seo()->tag('fb:image', 'foo');

expect(meta())->toContain('<meta property="fb:image" content="foo" />');
expect(meta())->toContain('<meta property="fb:image" content="foo">');
});

test('raw tags can be added to the template', function () {
Expand Down Expand Up @@ -114,8 +114,8 @@
seo()->withUrl();

expect(meta())
->toContain('<meta property="og:url" content="http://localhost" />')
->toContain('<link rel="canonical" href="http://localhost" />');
->toContain('<meta property="og:url" content="http://localhost">')
->toContain('<link rel="canonical" href="http://localhost">');
});

test('canonical url can be changed', function () {
Expand All @@ -124,8 +124,8 @@
seo()->url('http://foo.com/bar');

expect(meta())
->toContain('<meta property="og:url" content="http://foo.com/bar" />')
->toContain('<link rel="canonical" href="http://foo.com/bar" />');
->toContain('<meta property="og:url" content="http://foo.com/bar">')
->toContain('<link rel="canonical" href="http://foo.com/bar">');
});

test('og:title can be overridden using a tag', function () {
Expand All @@ -134,16 +134,16 @@

expect(meta())
->toContain('<title>foo</title>')
->toContain('<meta property="og:title" content="bar" />');
->toContain('<meta property="og:title" content="bar">');
});

test('type can be overridden using the type method', function () {
expect(meta())->toContain('<meta property="og:type" content="website" />'); // default
expect(meta())->toContain('<meta property="og:type" content="website">'); // default

seo()->type('foo');

expect(meta())
->toContain('<meta property="og:type" content="foo" />') // overridden
->toContain('<meta property="og:type" content="foo">') // overridden
->not()->toContain('website');
});

Expand All @@ -155,5 +155,5 @@
test('og:locale can be added to the template', function () {
seo()->locale('de_DE');

expect(meta())->toContain('<meta property="og:locale" content="de_DE" />');
expect(meta())->toContain('<meta property="og:locale" content="de_DE">');
});
12 changes: 6 additions & 6 deletions tests/Pest/SanitizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
expect($meta)->not()->toContain('content="Testing string " with several \' XSS characters </title> " . \' ."');
expect($meta)->not()->toContain("content=\"{$unsanitizedContent}\"");

expect($meta)->toContain("<meta property=\"$property\" content=\"{$sanitizedContent}\" />");
expect($meta)->toContain("<meta property=\"$property\" content=\"Testing string &quot; with several &#039; XSS characters &lt;/title&gt; &quot; . &#039; .\" />");
expect($meta)->toContain("<meta property=\"$property\" content=\"{$sanitizedContent}\">");
expect($meta)->toContain("<meta property=\"$property\" content=\"Testing string &quot; with several &#039; XSS characters &lt;/title&gt; &quot; . &#039; .\">");
})->with([
['site', 'og:site_name'],
['url', 'og:url'],
Expand All @@ -37,8 +37,8 @@
expect($meta)->not()->toContain('content="Testing string " with several \' XSS characters </title> " . \' ."');
expect($meta)->not()->toContain("content=\"{$unsanitizedContent}\"");

expect($meta)->toContain("<meta name=\"$property\" content=\"{$sanitizedContent}\" />");
expect($meta)->toContain("<meta name=\"$property\" content=\"Testing string &quot; with several &#039; XSS characters &lt;/title&gt; &quot; . &#039; .\" />");
expect($meta)->toContain("<meta name=\"$property\" content=\"{$sanitizedContent}\">");
expect($meta)->toContain("<meta name=\"$property\" content=\"Testing string &quot; with several &#039; XSS characters &lt;/title&gt; &quot; . &#039; .\">");
})->with([
['twitterCreator', 'twitter:creator'],
['twitterSite', 'twitter:site'],
Expand All @@ -65,8 +65,8 @@

expect($meta)->toContain("<title>{$sanitizedContent}</title>");
expect($meta)->toContain("<title>Testing string &quot; with several &#039; XSS characters &lt;/title&gt; &quot; . &#039; .</title>");
expect($meta)->toContain("<meta property=\"og:title\" content=\"{$sanitizedContent}\" />");
expect($meta)->toContain("<meta property=\"og:title\" content=\"Testing string &quot; with several &#039; XSS characters &lt;/title&gt; &quot; . &#039; .\" />");
expect($meta)->toContain("<meta property=\"og:title\" content=\"{$sanitizedContent}\">");
expect($meta)->toContain("<meta property=\"og:title\" content=\"Testing string &quot; with several &#039; XSS characters &lt;/title&gt; &quot; . &#039; .\">");
});

test('seo blade directive calls are sanitized', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/views/components/facebook.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<meta name="facebook:title" content="{{ strtoupper(seo()->facebookTitle) }}" />
<meta name="facebook:title" content="{{ strtoupper(seo()->facebookTitle) }}">

0 comments on commit c768bb7

Please sign in to comment.