Path: blob/trunk/rb/spec/unit/selenium/webdriver/bidi/cookies_spec.rb
4220 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__)20require File.expand_path('../../../../../lib/selenium/webdriver/bidi/network/cookies', __dir__)2122module Selenium23module WebDriver24class BiDi25describe Cookies do26let(:cookies) { described_class.new }2728it 'returns cookies formatted as json' do29cookies['session_id'] = 'xyz123'30cookies['user_pref'] = 'dark_mode'3132formatted_cookies = cookies.as_json33expect(formatted_cookies).to be_an(Array)34expect(formatted_cookies.size).to eq(2)3536session_cookie = formatted_cookies.find { |c| c[:name] == 'session_id' }37expect(session_cookie).not_to be_nil38expect(session_cookie[:value]).to eq({type: 'string', value: 'xyz123'})3940pref_cookie = formatted_cookies.find { |c| c[:name] == 'user_pref' }41expect(pref_cookie).not_to be_nil42expect(pref_cookie[:value]).to eq({type: 'string', value: 'dark_mode'})43end44end45end46end47end484950