From 647e7f2ac2dc8a0d4bb2312b733a464a00e2c8b9 Mon Sep 17 00:00:00 2001 From: Robin Malley Date: Sun, 26 Jun 2022 23:08:03 +0000 Subject: [PATCH] Add a unit test for posting Add a unit test that checks that the posting api works. --- spec/posting_spec.lua | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 spec/posting_spec.lua diff --git a/spec/posting_spec.lua b/spec/posting_spec.lua new file mode 100644 index 0000000..25cc954 --- /dev/null +++ b/spec/posting_spec.lua @@ -0,0 +1,40 @@ +_G.spy = spy +local mock_env = require("spec.env_mock") +local fuzzy = require("spec.fuzzgen") + +describe("smr",function() + setup(mock_env.setup) + teardown(mock_env.teardown) + it("should display an anonymously submitted post on the front page", function() + local paste_post = require("endpoints.paste_post") + local index_get = require("endpoints.index_get") + local pages = require("pages") + local config = require("config") + config.domain = "test.host" + pages_mock = mock(pages) + configure() + assert.stub(pages_mock.index).was_not_called() + local post_req = { + host = "test.host", + method = "POST", + path = "/_paste", + args = { + title = fuzzy.any(), + text = fuzzy.any(), + pasteas = "anonymous", + markup = "plain", + tags = "one;two;", + } + } + paste_post(post_req) + local get_req = { + host = "test.host", + method = "GET", + path = "/", + args = {}, + } + index_get(get_req) + assert.stub(pages_mock.index).was_called() + pending("TODO") + end) +end)