Skip to content

Commit 08720cf

Browse files
author
Ashu Goel
committed
[template_test] remove describe block since travis runs 1.2
1 parent 2309d2b commit 08720cf

File tree

1 file changed

+49
-51
lines changed

1 file changed

+49
-51
lines changed

test/template_test.exs

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -24,60 +24,58 @@ defmodule SparkPost.TemplateTest do
2424
end
2525
end
2626

27-
describe "preview tests" do
28-
test_with_mock "Template.preview succeeds with Template.ContentResponse",
29-
HTTPoison, [request: fn (method, url, body, headers, opts) ->
30-
assert method == :post
31-
# draft not set
32-
assert String.ends_with?(url, "preview")
33-
fun = MockServer.mk_http_resp(200, MockServer.get_json("previewtemplate"))
34-
fun.(method, url, body, headers, opts)
35-
end] do
36-
resp = Template.preview(TestStruct.basic_template(), TestStruct.substitution_data())
37-
assert %ContentResponse{} = resp
38-
end
27+
test_with_mock "Template.preview succeeds with Template.ContentResponse",
28+
HTTPoison, [request: fn (method, url, body, headers, opts) ->
29+
assert method == :post
30+
# draft not set
31+
assert String.ends_with?(url, "preview")
32+
fun = MockServer.mk_http_resp(200, MockServer.get_json("previewtemplate"))
33+
fun.(method, url, body, headers, opts)
34+
end] do
35+
resp = Template.preview(TestStruct.basic_template(), TestStruct.substitution_data())
36+
assert %ContentResponse{} = resp
37+
end
3938

40-
test_with_mock "Template.preview succeeds with Template.ContentResponse and draft set",
41-
HTTPoison, [request: fn (method, url, body, headers, opts) ->
42-
assert method == :post
43-
assert String.ends_with?(url, "preview?draft=true")
44-
fun = MockServer.mk_http_resp(200, MockServer.get_json("previewtemplate"))
45-
fun.(method, url, body, headers, opts)
46-
end] do
47-
resp = Template.preview(TestStruct.template_with_draft(), TestStruct.substitution_data())
48-
assert %ContentResponse{} = resp
49-
end
39+
test_with_mock "Template.preview succeeds with Template.ContentResponse and draft set",
40+
HTTPoison, [request: fn (method, url, body, headers, opts) ->
41+
assert method == :post
42+
assert String.ends_with?(url, "preview?draft=true")
43+
fun = MockServer.mk_http_resp(200, MockServer.get_json("previewtemplate"))
44+
fun.(method, url, body, headers, opts)
45+
end] do
46+
resp = Template.preview(TestStruct.template_with_draft(), TestStruct.substitution_data())
47+
assert %ContentResponse{} = resp
48+
end
5049

51-
test_with_mock "Template.preview fails with Endpoint.Error", HTTPoison,
52-
[request: MockServer.mk_fail] do
53-
resp = Template.preview(TestStruct.basic_template(), TestStruct.substitution_data())
54-
assert %Endpoint.Error{} = resp
55-
end
50+
test_with_mock "Template.preview fails with Endpoint.Error", HTTPoison,
51+
[request: MockServer.mk_fail] do
52+
resp = Template.preview(TestStruct.basic_template(), TestStruct.substitution_data())
53+
assert %Endpoint.Error{} = resp
54+
end
5655

57-
test_with_mock "Template.preview unmarshals complex from field correctly", HTTPoison,
58-
[request: fn (method, url, body, headers, opts) ->
59-
assert method == :post
60-
fun = MockServer.mk_http_resp(200, MockServer.get_json("previewtemplate"))
61-
fun.(method, url, body, headers, opts)
62-
end] do
63-
resp = Template.preview(TestStruct.basic_template(), TestStruct.substitution_data())
64-
assert %SparkPost.Address{
65-
name: "Example Company Marketing",
66-
"email": "marketing@bounces.company.example"
67-
} == resp.from
68-
end
56+
test_with_mock "Template.preview unmarshals complex from field correctly", HTTPoison,
57+
[request: fn (method, url, body, headers, opts) ->
58+
assert method == :post
59+
fun = MockServer.mk_http_resp(200, MockServer.get_json("previewtemplate"))
60+
fun.(method, url, body, headers, opts)
61+
end] do
62+
resp = Template.preview(TestStruct.basic_template(), TestStruct.substitution_data())
63+
assert %SparkPost.Address{
64+
name: "Example Company Marketing",
65+
"email": "marketing@bounces.company.example"
66+
} == resp.from
67+
end
6968

70-
test_with_mock "Template.preview unmarshals simple from field correctly", HTTPoison,
71-
[request: fn (method, url, body, headers, opts) ->
72-
assert method == :post
73-
fun = MockServer.mk_http_resp(200, MockServer.get_json("previewtemplate_simpleemail"))
74-
fun.(method, url, body, headers, opts)
75-
end] do
76-
resp = Template.preview(TestStruct.basic_template(), TestStruct.substitution_data())
77-
assert %SparkPost.Address{
78-
name: nil,
79-
"email": "marketing@bounces.company.example"
80-
} == resp.from
81-
end
69+
test_with_mock "Template.preview unmarshals simple from field correctly", HTTPoison,
70+
[request: fn (method, url, body, headers, opts) ->
71+
assert method == :post
72+
fun = MockServer.mk_http_resp(200, MockServer.get_json("previewtemplate_simpleemail"))
73+
fun.(method, url, body, headers, opts)
74+
end] do
75+
resp = Template.preview(TestStruct.basic_template(), TestStruct.substitution_data())
76+
assert %SparkPost.Address{
77+
name: nil,
78+
"email": "marketing@bounces.company.example"
79+
} == resp.from
8280
end
8381
end

0 commit comments

Comments
 (0)