-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagination_test.exs
71 lines (54 loc) · 1.99 KB
/
pagination_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
defmodule Simplates.PaginationTest do
use ExUnit.Case, async: true
alias Simplates.Pagination, as: Pagination
test "single page adds one code pages" do
pages = Pagination.parse_pages("<template>\nHello, world! I have no code!\n</template>")
assert pages.code.raw == ""
assert pages.templates[nil].raw == "Hello, world! I have no code!"
end
test "two page adds nothing" do
pages = Pagination.parse_pages("
<script>
some_code = 3
</script>
<template>
Hello, world! I have SOME code!
</template>")
assert String.trim(pages.code.raw) == "some_code = 3"
assert String.trim(pages.templates[nil].raw) == "Hello, world! I have SOME code!"
end
test "two page adds nothing with specline" do
pages = Pagination.parse_pages("
<script>
some_code = 2
</script>
<template type=\"media/type\" via=\"EEx\">
Hello, world! I have SOME code and a specline!
</template>")
assert String.trim(pages.code.raw) == "some_code = 2"
assert String.trim(pages.templates["media/type"].raw) == "Hello, world! I have SOME code and a specline!"
end
test "parser ignores any non-root level tags" do
pages = Pagination.parse_pages(~s(
<template>
This test ensures anything inside this template tag is ignored entirely by the parser.
<script>
food = "bar";
</script>
<template>
I could be a handlebars template or something, who knows :
</template>
</template>))
assert map_size(pages.templates) == 1
end
test "parser doesn't mess with htmlentities" do
pages = Pagination.parse_pages(~s(<template>\n<h2>this is a test</h2>\n</template>))
assert pages.templates[nil].raw == "<h2>this is a test</h2>"
end
test "parser handles two template tags" do
pages = Pagination.parse_pages(~s(<template type="text/html">\n</template>\n<template type="text/plain">\n</template>))
assert map_size(pages.templates) == 2
assert pages.templates["text/html"]
assert pages.templates["text/plain"]
end
end