Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 99e3df60d0
Fetching contributors…

Cannot retrieve contributors at this time

100 lines (87 sloc) 4.137 kB
# encoding: UTF-8
require "test_helper"
class FreeAgentTimelineTest < Test::Unit::TestCase
def setup
stub_free_agent_timeline!
end
def test_should_parse_vat_return_due_dates_from_feed
timeline = FreeAgent::Timeline.new("freerange", "api-key")
vat_returns = timeline.vat_returns
assert_equal 1, vat_returns.length
next_vat_return = vat_returns.first
assert_equal "VAT Return 01 12 Electronic Submission and Payment Due £23,769.28", next_vat_return.summary
assert_equal Date.parse("2012-03-07"), next_vat_return.due
end
def test_should_return_no_upcoming_vat_reminders_if_none_are_due_next_week
Timecop.travel(Date.parse("2012-02-26")) do
timeline = FreeAgent::Timeline.new("freerange", "api-key")
assert timeline.upcoming_vat_returns.empty?
end
end
def test_should_return_any_upcoming_vat_reminders_if_some_are_due_next_week
Timecop.travel(Date.parse("2012-02-27")) do
timeline = FreeAgent::Timeline.new("freerange", "api-key")
assert timeline.upcoming_vat_returns.any?
end
end
def test_should_parse_annual_return_due_dates_from_feed
timeline = FreeAgent::Timeline.new("freerange", "api-key")
annual_returns = timeline.annual_returns
assert_equal 3, annual_returns.length
next_annual_return = annual_returns.first
assert_equal "Annual Return as at 01-01-2012 Companies House Annual Return Due", next_annual_return.summary.strip
assert_equal Date.parse("2012-01-29"), next_annual_return.due
end
def test_should_return_no_upcoming_annual_reminders_if_none_are_due_next_week
Timecop.travel(Date.parse("2012-01-09")) do
timeline = FreeAgent::Timeline.new("freerange", "api-key")
assert timeline.upcoming_annual_returns.empty?
end
end
def test_should_return_any_upcoming_annual_return_reminders_if_some_are_due_next_week
Timecop.travel(Date.parse("2012-01-16")) do
timeline = FreeAgent::Timeline.new("freerange", "api-key")
assert timeline.upcoming_annual_returns.any?
end
end
def test_should_parse_corporation_tax_payment_due_dates_from_feed
timeline = FreeAgent::Timeline.new("freerange", "api-key")
corporation_tax_due = timeline.corporation_tax_payments
assert_equal 1, corporation_tax_due.length
next_corp_tax = corporation_tax_due.first
assert_equal "Corporation Tax\, year ending 31 Jan 12 Payment Due £70\,635.61", next_corp_tax.summary.strip
assert_equal Date.parse("2012-11-01"), next_corp_tax.due
end
def test_should_return_no_upcoming_corporation_tax_payments_if_none_are_due_next_week
Timecop.travel(Date.parse("2012-10-15")) do
timeline = FreeAgent::Timeline.new("freerange", "api-key")
assert timeline.upcoming_corporation_tax_payments.empty?
end
end
def test_should_return_any_upcoming_corporation_tax_payments_if_some_are_due_next_week
Timecop.travel(Date.parse("2012-10-22")) do
timeline = FreeAgent::Timeline.new("freerange", "api-key")
assert timeline.upcoming_corporation_tax_payments.any?
end
end
def test_should_parse_corporation_tax_submissions_due_dates_from_feed
timeline = FreeAgent::Timeline.new("freerange", "api-key")
corporation_tax_return_due = timeline.corporation_tax_submissions
assert_equal 2, corporation_tax_return_due.length
next_corp_tax_return = corporation_tax_return_due.first
assert_equal "Corporation Tax\, year ending 31 Jan 11 Submission Due", next_corp_tax_return.summary.strip
assert_equal Date.parse("2012-01-31"), next_corp_tax_return.due
end
def test_should_return_no_upcoming_corporation_tax_submissions_if_none_are_due_next_week
Timecop.travel(Date.parse("2012-01-16")) do
timeline = FreeAgent::Timeline.new("freerange", "api-key")
assert timeline.upcoming_corporation_tax_submissions.empty?
end
end
def test_should_return_any_upcoming_corporation_tax_submissions_if_some_are_due_next_week
Timecop.travel(Date.parse("2012-01-23")) do
timeline = FreeAgent::Timeline.new("freerange", "api-key")
assert timeline.upcoming_corporation_tax_submissions.any?
end
end
end
Jump to Line
Something went wrong with that request. Please try again.