Path: blob/trunk/rb/spec/unit/selenium/webdriver/common/interactions/interactions_spec.rb
1865 views
# frozen_string_literal: true12# Licensed to the Software Freedom Conservancy (SFC) under one3# or more contributor license agreements. See the NOTICE file4# distributed with this work for additional information5# regarding copyright ownership. The SFC licenses this file6# to you under the Apache License, Version 2.0 (the7# "License"); you may not use this file except in compliance8# with the License. You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing,13# software distributed under the License is distributed on an14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15# KIND, either express or implied. See the License for the16# specific language governing permissions and limitations17# under the License.1819require File.expand_path('../../spec_helper', __dir__)2021module Selenium22module WebDriver23describe Interactions do24describe '#key' do25it 'creates a new key input with provided name' do26device = described_class.key(:name)2728expect(device).to be_a(Interactions::KeyInput)29expect(device.name).to eq(:name)30end3132it 'sets name to a random UUID if no name is provided' do33allow(SecureRandom).to receive(:uuid).and_return(:id)3435device = described_class.key3637expect(device).to be_a(Interactions::KeyInput)38expect(device.name).to eq(:id)39end40end4142describe '#pointer' do43it 'creates a new pointer input with a provided name' do44device = described_class.pointer(:mouse, name: :name)4546expect(device).to be_a(Interactions::PointerInput)47expect(device.name).to eq(:name)48end4950it 'sets name to a random UUID if no name is provided' do51allow(SecureRandom).to receive(:uuid).and_return(:id)5253device = described_class.pointer(:mouse)5455expect(device).to be_a(Interactions::PointerInput)56expect(device.name).to eq(:id)57end58end5960describe '#none' do61it 'creates a new pointer input with a provided name' do62device = described_class.none(:name)6364expect(device).to be_a(Interactions::NoneInput)65expect(device.name).to eq(:name)66end6768it 'sets name to a random UUID if no name is provided' do69allow(SecureRandom).to receive(:uuid).and_return(:id)7071device = described_class.none7273expect(device).to be_a(Interactions::NoneInput)74expect(device.name).to eq(:id)75end76end77end78end # WebDriver79end # Selenium808182