Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/spec/unit/selenium/webdriver/common/fedcm/dialog_spec.rb
1865 views
1
# frozen_string_literal: true
2
3
# Licensed to the Software Freedom Conservancy (SFC) under one
4
# or more contributor license agreements. See the NOTICE file
5
# distributed with this work for additional information
6
# regarding copyright ownership. The SFC licenses this file
7
# to you under the Apache License, Version 2.0 (the
8
# "License"); you may not use this file except in compliance
9
# with the License. You may obtain a copy of the License at
10
#
11
# http://www.apache.org/licenses/LICENSE-2.0
12
#
13
# Unless required by applicable law or agreed to in writing,
14
# software distributed under the License is distributed on an
15
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
# KIND, either express or implied. See the License for the
17
# specific language governing permissions and limitations
18
# under the License.
19
20
require File.expand_path('../../spec_helper', __dir__)
21
22
module Selenium
23
module WebDriver
24
module FedCM
25
describe Dialog do
26
let(:bridge) { instance_double(Remote::Bridge) }
27
let(:dialog) { described_class.new(bridge) }
28
29
describe '#click' do
30
it 'calls click_fedcm_dialog on the bridge' do
31
allow(bridge).to receive(:click_fedcm_dialog_button).and_return(nil)
32
expect(dialog.click).to be_nil
33
end
34
end
35
36
describe '#cancel' do
37
it 'calls cancel_fedcm_dialog on the bridge' do
38
allow(bridge).to receive(:cancel_fedcm_dialog).and_return(nil)
39
expect(dialog.cancel).to be_nil
40
end
41
end
42
43
describe '#select_account' do
44
it 'calls select_fedcm_account on the bridge with the given index' do
45
index = 1
46
allow(bridge).to receive(:select_fedcm_account).with(index).and_return(nil)
47
expect(dialog.select_account(index)).to be_nil
48
end
49
end
50
51
describe '#type' do
52
it 'returns the type of the open dialog' do
53
allow(bridge).to receive(:fedcm_dialog_type).and_return('AccountChooser')
54
expect(dialog.type).to eq('AccountChooser')
55
end
56
end
57
58
describe '#title' do
59
it 'returns the title of the dialog' do
60
allow(bridge).to receive(:fedcm_title).and_return('Sign in')
61
expect(dialog.title).to eq('Sign in')
62
end
63
end
64
65
describe '#subtitle' do
66
it 'returns the subtitle of the dialog' do
67
allow(bridge).to receive(:fedcm_subtitle).and_return('Choose an account')
68
expect(dialog.subtitle).to eq('Choose an account')
69
end
70
71
it 'returns nil if there is no subtitle' do
72
allow(bridge).to receive(:fedcm_subtitle).and_return(nil)
73
expect(dialog.subtitle).to be_nil
74
end
75
end
76
77
describe '#accounts' do
78
it 'returns the accounts shown in the account chooser' do
79
accounts_data = [{'name' => 'Account1', 'email' => '[email protected]'},
80
{'name' => 'Account2', 'email' => '[email protected]'}]
81
allow(bridge).to receive(:fedcm_account_list).and_return(accounts_data)
82
accounts = dialog.accounts
83
expect(accounts.size).to eq(2)
84
expect(accounts[0].name).to eq('Account1')
85
expect(accounts[0].email).to eq('[email protected]')
86
expect(accounts[1].name).to eq('Account2')
87
expect(accounts[1].email).to eq('[email protected]')
88
end
89
end
90
end # Dialog
91
end # FedCM
92
end # WebDriver
93
end # Selenium
94
95