Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Dec 20, 2020
1 parent 98c7945 commit b5616b6
Show file tree
Hide file tree
Showing 281 changed files with 2,262 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/cases/attrs-data.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<foo data-user="{&quot;name&quot;:&quot;tobi&quot;}"></foo>
<foo data-items="[1,2,3]"></foo>
<foo data-username="tobi"></foo>
<foo data-escaped="{&quot;message&quot;:&quot;Let's rock!&quot;}"></foo>
<foo data-ampersand="{&quot;message&quot;:&quot;a quote: &amp;quot; this &amp; that&quot;}"></foo>
<foo data-epoc="1970-01-01T00:00:00.000Z"></foo>
7 changes: 7 additions & 0 deletions tests/cases/attrs-data.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- var user = { name: 'tobi' }
foo(data-user=user)
foo(data-items=[1,2,3])
foo(data-username='tobi')
foo(data-escaped={message: "Let's rock!"})
foo(data-ampersand={message: "a quote: &quot; this & that"})
foo(data-epoc=new Date(0))
1 change: 1 addition & 0 deletions tests/cases/attrs.colon.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div :my-var="model"></div><span v-for="item in items" :key="item.id" :value="item.name"></span><span v-for="item in items" :key="item.id" :value="item.name"></span><a :link="goHere" value="static" :my-value="dynamic" @click="onClick()" :another="more">Click Me!</a>
9 changes: 9 additions & 0 deletions tests/cases/attrs.colon.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//- Tests for using a colon-prefexed attribute (typical when using short-cut for Vue.js `v-bind`)
div(:my-var="model")
span(v-for="item in items" :key="item.id" :value="item.name")
span(
v-for="item in items"
:key="item.id"
:value="item.name"
)
a(:link="goHere" value="static" :my-value="dynamic" @click="onClick()" :another="more") Click Me!
20 changes: 20 additions & 0 deletions tests/cases/attrs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<a href="/contact">contact</a><a class="button" href="/save">save</a><a foo="foo" bar="bar" baz="baz"></a><a foo="foo, bar, baz" bar="1"></a><a foo="((foo))" bar="1"></a>
<select>
<option value="foo" selected="selected">Foo</option>
<option selected="selected" value="bar">Bar</option>
</select><a foo="class:"></a>
<input pattern="\S+"/><a href="/contact">contact</a><a class="button" href="/save">save</a><a foo="foo" bar="bar" baz="baz"></a><a foo="foo, bar, baz" bar="1"></a><a foo="((foo))" bar="1"></a>
<select>
<option value="foo" selected="selected">Foo</option>
<option selected="selected" value="bar">Bar</option>
</select><a foo="class:"></a>
<input pattern="\S+"/>
<foo terse="true"></foo>
<foo date="1970-01-01T00:00:00.000Z"></foo>
<foo abc="abc" def="def"></foo>
<foo abc="abc" def="def"></foo>
<foo abc="abc" def="def"></foo>
<foo abc="abc" def="def"></foo>
<foo abc="abc" def="def"></foo>
<foo abc="abc" def="def"></foo>
<div foo="bar" bar="<baz>"></div><a foo="foo" bar="bar"></a><a foo="foo" bar="bar"></a>
5 changes: 5 additions & 0 deletions tests/cases/attrs.js.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<a class="button" href="/user/5"></a><a class="button" href="/user/5"></a>
<meta key="answer" value="42"/><a class="class1 class2"></a><a class="tag-class class1 class2"></a><a class="button" href="/user/5"></a><a class="button" href="/user/5"></a>
<meta key="answer" value="42"/><a class="class1 class2"></a><a class="tag-class class1 class2"></a>
<div id="5" foo="bar"></div>
<div baz="baz"></div>
17 changes: 17 additions & 0 deletions tests/cases/attrs.js.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- var id = 5
- function answer() { return 42; }
a(href='/user/' + id, class='button')
a(href = '/user/' + id, class = 'button')
meta(key='answer', value=answer())
a(class = ['class1', 'class2'])
a.tag-class(class = ['class1', 'class2'])

a(href='/user/' + id class='button')
a(href = '/user/' + id class = 'button')
meta(key='answer' value=answer())
a(class = ['class1', 'class2'])
a.tag-class(class = ['class1', 'class2'])

div(id=id)&attributes({foo: 'bar'})
- var bar = null
div(foo=null bar=bar)&attributes({baz: 'baz'})
43 changes: 43 additions & 0 deletions tests/cases/attrs.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
a(href='/contact') contact
a(href='/save').button save
a(foo, bar, baz)
a(foo='foo, bar, baz', bar=1)
a(foo='((foo))', bar= (1) ? 1 : 0 )
select
option(value='foo', selected) Foo
option(selected, value='bar') Bar
a(foo="class:")
input(pattern='\\S+')

a(href='/contact') contact
a(href='/save').button save
a(foo bar baz)
a(foo='foo, bar, baz' bar=1)
a(foo='((foo))' bar= (1) ? 1 : 0 )
select
option(value='foo' selected) Foo
option(selected value='bar') Bar
a(foo="class:")
input(pattern='\\S+')
foo(terse="true")
foo(date=new Date(0))

foo(abc
,def)
foo(abc,
def)
foo(abc,
def)
foo(abc
,def)
foo(abc
def)
foo(abc
def)

- var attrs = {foo: 'bar', bar: '<baz>'}

div&attributes(attrs)

a(foo='foo' "bar"="bar")
a(foo='foo' 'bar'='bar')
5 changes: 5 additions & 0 deletions tests/cases/attrs.unescaped.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script type="text/x-template">
<div id="user-<%= user.id %>">
<h1><%= user.title %></h1>
</div>
</script>
3 changes: 3 additions & 0 deletions tests/cases/attrs.unescaped.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
script(type='text/x-template')
div(id!='user-<%= user.id %>')
h1 <%= user.title %>
1 change: 1 addition & 0 deletions tests/cases/auxiliary/1794-extends.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
block content
4 changes: 4 additions & 0 deletions tests/cases/auxiliary/1794-include.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mixin test()
.test&attributes(attributes)

+test()
8 changes: 8 additions & 0 deletions tests/cases/auxiliary/blocks-in-blocks-layout.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
doctype html
html
head
title Default title
body
block body
.container
block content
6 changes: 6 additions & 0 deletions tests/cases/auxiliary/dialog.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

extends window.pug

block window-content
.dialog
block content
2 changes: 2 additions & 0 deletions tests/cases/auxiliary/empty-block.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
block test

3 changes: 3 additions & 0 deletions tests/cases/auxiliary/escapes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
console.log("foo\nbar")
</script>
5 changes: 5 additions & 0 deletions tests/cases/auxiliary/extends-empty-block-1.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends empty-block.pug

block test
div test1

5 changes: 5 additions & 0 deletions tests/cases/auxiliary/extends-empty-block-2.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends empty-block.pug

block test
div test2

4 changes: 4 additions & 0 deletions tests/cases/auxiliary/extends-from-root.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends /auxiliary/layout.pug

block content
include /auxiliary/include-from-root.pug
4 changes: 4 additions & 0 deletions tests/cases/auxiliary/extends-relative.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends ../../cases/auxiliary/layout

block content
include ../../cases/auxiliary/include-from-root
8 changes: 8 additions & 0 deletions tests/cases/auxiliary/filter-in-include.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
html
head
style(type="text/css")
:less
@pad: 15px;
body {
padding: @pad;
}
8 changes: 8 additions & 0 deletions tests/cases/auxiliary/includable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var STRING_SUBSTITUTIONS = {
// table of character substitutions
"\t": "\\t",
"\r": "\\r",
"\n": "\\n",
'"': '\\"',
"\\": "\\\\",
};
1 change: 1 addition & 0 deletions tests/cases/auxiliary/include-from-root.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1 hello
11 changes: 11 additions & 0 deletions tests/cases/auxiliary/inheritance.extend.mixin.block.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mixin article()
article
block

html
head
title My Application
block head
body
+article
block content
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
h1 grand-grandparent
block grand-grandparent
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends inheritance.extend.recursive-grand-grandparent.pug

block grand-grandparent
h2 grandparent
block grandparent

5 changes: 5 additions & 0 deletions tests/cases/auxiliary/inheritance.extend.recursive-parent.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends inheritance.extend.recursive-grandparent.pug

block grandparent
h3 parent
block parent
7 changes: 7 additions & 0 deletions tests/cases/auxiliary/layout.include.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
html
head
title My Application
block head
body
block content
include window.pug
6 changes: 6 additions & 0 deletions tests/cases/auxiliary/layout.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
html
head
title My Application
block head
body
block content
3 changes: 3 additions & 0 deletions tests/cases/auxiliary/mixin-at-end-of-file.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mixin slide
section.slide
block
3 changes: 3 additions & 0 deletions tests/cases/auxiliary/mixins.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

mixin foo()
p bar
3 changes: 3 additions & 0 deletions tests/cases/auxiliary/pet.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pet
h1 {{name}}
p {{name}} is a {{species}} that is {{age}} old
1 change: 1 addition & 0 deletions tests/cases/auxiliary/smile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>:)</p>
4 changes: 4 additions & 0 deletions tests/cases/auxiliary/window.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

.window
a(href='#').close Close
block window-content
10 changes: 10 additions & 0 deletions tests/cases/auxiliary/yield-nested.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
html
head
title
body
h1 Page
#content
#content-wrapper
yield
#footer
stuff
5 changes: 5 additions & 0 deletions tests/cases/basic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
<h1>Title</h1>
</body>
</html>
3 changes: 3 additions & 0 deletions tests/cases/basic.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html
body
h1 Title
5 changes: 5 additions & 0 deletions tests/cases/blanks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul>
8 changes: 8 additions & 0 deletions tests/cases/blanks.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


ul
li foo

li bar

li baz
7 changes: 7 additions & 0 deletions tests/cases/block-code.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

<li>Uno</li>
<li>Dos</li>
<li>Tres</li>
<li>Cuatro</li>
<li>Cinco</li>
<li>Seis</li>
12 changes: 12 additions & 0 deletions tests/cases/block-code.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-
list = ["uno", "dos", "tres",
"cuatro", "cinco", "seis"];
//- Without a block, the element is accepted and no code is generated
-
each item in list
-
string = item.charAt(0)
.toUpperCase() +
item.slice(1);
li= string
5 changes: 5 additions & 0 deletions tests/cases/block-expansion.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ul>
<li><a href="#">foo</a></li>
<li><a href="#">bar</a></li>
</ul>
<p>baz</p>
5 changes: 5 additions & 0 deletions tests/cases/block-expansion.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ul
li: a(href='#') foo
li: a(href='#') bar

p baz
7 changes: 7 additions & 0 deletions tests/cases/block-expansion.shorthands.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<ul>
<li class="list-item">
<div class="foo">
<div id="bar">baz</div>
</div>
</li>
</ul>
2 changes: 2 additions & 0 deletions tests/cases/block-expansion.shorthands.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ul
li.list-item: .foo: #bar baz
4 changes: 4 additions & 0 deletions tests/cases/blockquote.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<figure>
<blockquote>Try to define yourself by what you do, and you&#8217;ll burnout every time. You are. That is enough. I rest in that.</blockquote>
<figcaption>from @thefray at 1:43pm on May 10</figcaption>
</figure>
4 changes: 4 additions & 0 deletions tests/cases/blockquote.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
figure
blockquote
| Try to define yourself by what you do, and you&#8217;ll burnout every time. You are. That is enough. I rest in that.
figcaption from @thefray at 1:43pm on May 10
9 changes: 9 additions & 0 deletions tests/cases/blocks-in-blocks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Default title</title>
</head>
<body>
<h1>Page 2</h1>
</body>
</html>
4 changes: 4 additions & 0 deletions tests/cases/blocks-in-blocks.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends ./auxiliary/blocks-in-blocks-layout.pug

block body
h1 Page 2
1 change: 1 addition & 0 deletions tests/cases/blocks-in-if.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>ajax contents</p>
Loading

0 comments on commit b5616b6

Please sign in to comment.