ref: master
test/unit/contact_list_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
require_relative "../test_helper" class ContactListTest < ActiveSupport::TestCase should 'have list as an array' do assert_equal [], ContactList.create.list end should 'display list' do contact_list = ContactList.create.tap do |c| c.list = ['email1@noosfero.org', 'email2@noosfero.org'] end assert_equal ['email1@noosfero.org', 'email2@noosfero.org'], contact_list.list end should 'return empty hash if contact list was not fetched' do contact_list = ContactList.create assert_equal({}, contact_list.data) end should 'return hash if contact list was fetched' do contact_list = ContactList.create.tap do |c| c.fetched = true end assert_equal({"fetched" => true, "contact_list" => contact_list.id, "error" => contact_list.error_fetching}, contact_list.data) end should 'update fetched and error_fetching when register auth error' do contact_list = ContactList.create assert_equal({}, contact_list.data) contact_list.register_error assert_equal({"fetched" => true, "contact_list" => contact_list.id, "error" => 'There was an error while looking for your contact list. Please, try again'}, contact_list.data) end should 'update fetched and error_fetching when register error' do contact_list = ContactList.create assert_equal({}, contact_list.data) contact_list.register_auth_error assert_equal({"fetched" => true, "contact_list" => contact_list.id, "error" => 'There was an error while authenticating. Did you enter correct login and password?'}, contact_list.data) end end |