Add a unit test for posting
Add a unit test that checks that the posting api works.
This commit is contained in:
		
							parent
							
								
									3b1d3dd910
								
							
						
					
					
						commit
						647e7f2ac2
					
				|  | @ -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) | ||||||
		Loading…
	
		Reference in New Issue