update: add querystring
This commit is contained in:
parent
1e0329a597
commit
0a0c7c9e8b
3 changed files with 100 additions and 3 deletions
|
|
@ -772,3 +772,37 @@ test "parse partial uso" {
|
|||
try testing.expect(nodes[1].type == .partial);
|
||||
try testing.expectEqualStrings("cabecalho", nodes[1].partial.?.name);
|
||||
}
|
||||
|
||||
test "parse querystring simples" {
|
||||
const allocator = testing.allocator;
|
||||
const template = "Link: {% querystring \"page=2\" %}";
|
||||
const nodes = try parser.parse(allocator, template);
|
||||
defer {
|
||||
for (nodes) |node| node.deinit(allocator);
|
||||
allocator.free(nodes);
|
||||
}
|
||||
|
||||
try testing.expectEqual(@as(usize, 2), nodes.len);
|
||||
try testing.expect(nodes[1].type == .querystring);
|
||||
const qs = nodes[1].querystring.?;
|
||||
try testing.expectEqual(@as(usize, 1), qs.modifications.len);
|
||||
try testing.expectEqualStrings("page=2", qs.modifications[0]);
|
||||
}
|
||||
|
||||
test "parse querystring múltiplos" {
|
||||
const allocator = testing.allocator;
|
||||
const template = "{% querystring \"ordenar=-nome\" \"pagina\" None %}";
|
||||
const nodes = try parser.parse(allocator, template);
|
||||
defer {
|
||||
for (nodes) |node| node.deinit(allocator);
|
||||
allocator.free(nodes);
|
||||
}
|
||||
|
||||
try testing.expectEqual(@as(usize, 1), nodes.len);
|
||||
try testing.expect(nodes[0].type == .querystring);
|
||||
const qs = nodes[0].querystring.?;
|
||||
try testing.expectEqual(@as(usize, 3), qs.modifications.len);
|
||||
try testing.expectEqualStrings("ordenar=-nome", qs.modifications[0]);
|
||||
try testing.expectEqualStrings("pagina", qs.modifications[1]);
|
||||
try testing.expectEqualStrings("None", qs.modifications[2]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue