From d23949aeaf4e3250ed3057f9daa5da0c5f773dae Mon Sep 17 00:00:00 2001 From: John Maguire Date: Tue, 16 Oct 2018 08:25:03 -0400 Subject: [PATCH] removed uneeded google maps call --- .circleci/config.yml | 5 - .eslintrc | 1 - Gemfile | 2 - Gemfile.lock | 18 - app/assets/javascripts/application.js | 1 - app/assets/javascripts/load_page.js | 3 - app/views/devise/registrations/edit.html.erb | 8 +- app/views/devise/registrations/new.html.erb | 4 +- app/views/layouts/application.html.erb | 6 - client/app/components/Input/InputLocation.jsx | 3 +- client/app/components/Input/index.jsx | 3 +- client/yarn.lock | 4 +- config/jshint.yml | 21 - ...sting_browser_locale_after_sign_in_spec.rb | 3 +- spec/javascripts/GetLocationSpec.js | 27 - spec/javascripts/fixtures/get_location.html | 1 - spec/javascripts/helpers/jasmine-jquery.js | 841 ------------------ spec/javascripts/helpers/key-press.js | 6 - spec/javascripts/support/jasmine.yml | 135 --- spec/javascripts/support/jasmine_helper.rb | 16 - 20 files changed, 16 insertions(+), 1092 deletions(-) delete mode 100644 app/assets/javascripts/load_page.js delete mode 100644 config/jshint.yml delete mode 100644 spec/javascripts/GetLocationSpec.js delete mode 100644 spec/javascripts/fixtures/get_location.html delete mode 100644 spec/javascripts/helpers/jasmine-jquery.js delete mode 100644 spec/javascripts/helpers/key-press.js delete mode 100644 spec/javascripts/support/jasmine.yml delete mode 100644 spec/javascripts/support/jasmine_helper.rb diff --git a/.circleci/config.yml b/.circleci/config.yml index e9ff5e03ab..3a94c9fcfa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -103,11 +103,6 @@ jobs: root: tmp paths: - codeclimate.backend.json - - run: - name: Run Rails Jasmine Tests - command: | - set -e - RAILS_ENV=test bundle exec rake jasmine:ci - run: bundle exec bundle-audit check --update - store_test_results: path: /tmp/circleci-test-results diff --git a/.eslintrc b/.eslintrc index 9faa37508e..34ce3b453a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,7 +6,6 @@ env: amd: true browser: true es6: true - jquery: true node: true # http://eslint.org/docs/rules/ diff --git a/Gemfile b/Gemfile index a131abf554..9bf050e4fb 100644 --- a/Gemfile +++ b/Gemfile @@ -64,7 +64,6 @@ group :development, :test do gem 'capybara', '~> 3.12.0' gem 'chromedriver-helper' gem 'factory_bot_rails' - gem 'jasmine', '~> 2.7.0' gem 'rspec-collection_matchers', '~> 1.1.3' gem 'rspec-html-matchers', '~> 0.9.0' gem 'rspec-rails', '~> 3.8.1' @@ -72,7 +71,6 @@ group :development, :test do gem 'letter_opener' gem 'rspec_junit_formatter' - gem 'jshint' gem 'rubocop', '>= 0.49.0' gem 'rubocop-rspec' diff --git a/Gemfile.lock b/Gemfile.lock index 87e3ccd478..382de7d186 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -167,12 +167,6 @@ GEM nokogiri (>= 1.6) io-like (0.3.0) jaro_winkler (1.5.1) - jasmine (2.7.0) - jasmine-core (>= 2.7.0, < 3.0.0) - phantomjs - rack (>= 1.2.1) - rake - jasmine-core (2.99.2) jbuilder (2.8.0) activesupport (>= 4.2.0) multi_json (>= 1.2) @@ -180,10 +174,6 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jshint (1.5.0) - execjs (>= 1.4.0) - multi_json (~> 1.0) - therubyracer (~> 0.12.1) json (2.1.0) jwt (1.5.6) kaminari (1.1.1) @@ -202,7 +192,6 @@ GEM addressable (~> 2.3) letter_opener (1.6.0) launchy (~> 2.2) - libv8 (3.16.14.19) loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -250,7 +239,6 @@ GEM parser (2.5.3.0) ast (~> 2.4.0) pg (1.1.3) - phantomjs (2.1.1.0) powerpack (0.1.2) pry (0.12.0) coderay (~> 1.1.0) @@ -331,7 +319,6 @@ GEM redis (4.0.2) redis-namespace (1.6.0) redis (>= 3.0.4) - ref (2.0.0) regexp_parser (1.3.0) representable (3.0.4) declarative (< 0.1.0) @@ -443,9 +430,6 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - therubyracer (0.12.3) - libv8 (~> 3.16.14.15) - ref thor (0.19.4) thread_safe (0.3.6) tilt (2.0.8) @@ -504,10 +488,8 @@ DEPENDENCIES google-api-client (~> 0.25.0) groupdate (= 4.1.0) inline_svg - jasmine (~> 2.7.0) jbuilder (~> 2.8.0) jquery-rails (= 4.1.1) - jshint kaminari (= 1.1.1) letter_opener omniauth (~> 1.8.1) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e211523714..d6925fa431 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -10,7 +10,6 @@ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details // about supported directives. // -//= require load_page.js //= require jquery //= require jquery_ujs //= require turbolinks diff --git a/app/assets/javascripts/load_page.js b/app/assets/javascripts/load_page.js deleted file mode 100644 index a5266ca088..0000000000 --- a/app/assets/javascripts/load_page.js +++ /dev/null @@ -1,3 +0,0 @@ -function loadPage(event) { - document.addEventListener('turbolinks:load', event); -} diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index e947734fc7..a3c9cf6aca 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -5,7 +5,13 @@ <%= f.text_field :name, 'aria-label': t('common.name') %>
<%= t('common.form.location') %>
- <%= react_component 'Input', props: { type: 'location', placeholder: t('devise.registrations.edit.placeholders.optional'), googleAPIKey: ENV['GOOGLE_API_KEY'], id: 'user_input'} %> + <%= react_component 'Input', props: { + type: 'location', + placeholder: t('devise.registrations.edit.placeholders.optional'), + googleAPIKey: ENV['GOOGLE_API_KEY'], + id: 'user_input', + value: current_user.location || nil + } %>
<%= t('common.form.email') %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 0791737969..b20dba8607 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -9,7 +9,9 @@
<%= t('devise.registrations.new.label') %>
<%= react_component 'Input', props: { type: 'location', placeholder: t('common.form.location'), googleAPIKey: ENV['GOOGLE_API_KEY'], id: 'user_input'} %> - <%= f.email_field :email, placeholder: t('common.form.email'), 'aria-label': t('common.form.email') %> +
+ <%= f.email_field :email, placeholder: t('common.form.email'), 'aria-label': t('common.form.email') %> +
<%= t('devise.password') %>
<%= f.password_field :password, autocomplete: 'off', class: 'smallMarginBottom', placeholder: t('devise.password'), 'aria-label': t('devise.password') %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 5011ce2ee0..47b70e1aba 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -45,12 +45,6 @@ <%= javascript_include_tag pusher_url, async: true %> <%= tag :meta, name: 'pusher-key', content: ENV['PUSHER_KEY'] %> <% end %> - - <% if join_path? || update_account_path? %> - - <% google_maps_url = "https://maps.googleapis.com/maps/api/js?key=#{ENV['GOOGLE_API_KEY']}&libraries=places" %> - - <% end %> diff --git a/client/app/components/Input/InputLocation.jsx b/client/app/components/Input/InputLocation.jsx index 8870eaf96a..d1f38aa11c 100644 --- a/client/app/components/Input/InputLocation.jsx +++ b/client/app/components/Input/InputLocation.jsx @@ -7,6 +7,7 @@ export type Props = { placeholder: string, apiKey: string, id: string, + value?: any, }; export type State = { @@ -16,7 +17,7 @@ export type State = { export class InputLocation extends React.Component { constructor(props: Props) { super(props); - this.state = { address: '' }; + this.state = { address: props.value || '' }; } handleChange = (event: SyntheticInputEvent) => { diff --git a/client/app/components/Input/index.jsx b/client/app/components/Input/index.jsx index 49ad1de01a..55cbd65820 100644 --- a/client/app/components/Input/index.jsx +++ b/client/app/components/Input/index.jsx @@ -240,11 +240,12 @@ export class Input extends React.Component { displayLocation = () => { const { - type, placeholder, googleAPIKey, id, + type, placeholder, googleAPIKey, id, value, } = this.props; if (type === 'location' && placeholder && googleAPIKey) { return ( >>>>>> moved to using react component for input autocomplete react@^16.4.0: version "16.5.2" diff --git a/config/jshint.yml b/config/jshint.yml deleted file mode 100644 index 49a2bcee7a..0000000000 --- a/config/jshint.yml +++ /dev/null @@ -1,21 +0,0 @@ -files: ["**/*.js"] # No need to put app/assets/ or vendor/assets here -exclude_paths: [] -options: - boss: true - browser: true - curly: true - eqeqeq: true - eqnull: true - expr: true - immed: true - indent: 2 - latedef: true - newcap: true - noarg: true - sub: true - trailing: true - undef: true - unused: true - globals: - jQuery: true - "$": true diff --git a/spec/features/persisting_browser_locale_after_sign_in_spec.rb b/spec/features/persisting_browser_locale_after_sign_in_spec.rb index 97be185275..86f1135178 100644 --- a/spec/features/persisting_browser_locale_after_sign_in_spec.rb +++ b/spec/features/persisting_browser_locale_after_sign_in_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true - -RSpec.feature 'Persisting browser locale after sign in', type: :feature do +feature 'Persisting browser locale after sign in', type: :feature do scenario 'When user sign in, sign out, then change local', js: true, header: true do user = create :user diff --git a/spec/javascripts/GetLocationSpec.js b/spec/javascripts/GetLocationSpec.js deleted file mode 100644 index d45b1c6727..0000000000 --- a/spec/javascripts/GetLocationSpec.js +++ /dev/null @@ -1,27 +0,0 @@ -describe('GetLocation', function() { - var getLocation; - - describe('initAutocomplete', function() { - beforeEach(function() { - getLocation = spyOn(window, 'getLocation'); - }); - - it('does not call getLocation() if #user_location is not found', function() { - initAutocomplete(); - expect(getLocation).not.toHaveBeenCalled(); - }); - - it('does not call getLocation() if google object is not valid', function() { - google = true; - initAutocomplete(); - expect(getLocation).not.toHaveBeenCalled(); - }); - - it('calls getLocation() if #user_location is found and google object is valid', function() { - google = { maps: {} }; - loadFixtures('get_location.html'); - initAutocomplete(); - expect(getLocation).toHaveBeenCalled(); - }); - }); -}); diff --git a/spec/javascripts/fixtures/get_location.html b/spec/javascripts/fixtures/get_location.html deleted file mode 100644 index b012d39300..0000000000 --- a/spec/javascripts/fixtures/get_location.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/spec/javascripts/helpers/jasmine-jquery.js b/spec/javascripts/helpers/jasmine-jquery.js deleted file mode 100644 index e817e64722..0000000000 --- a/spec/javascripts/helpers/jasmine-jquery.js +++ /dev/null @@ -1,841 +0,0 @@ -/*! - Jasmine-jQuery: a set of jQuery helpers for Jasmine tests. - - Version 2.1.1 - - https://github.com/velesin/jasmine-jquery - - Copyright (c) 2010-2014 Wojciech Zawistowski, Travis Jeffery - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -(function (root, factory) { - if (typeof module !== 'undefined' && module.exports) { - factory(root, root.jasmine, require('jquery')); - } else { - factory(root, root.jasmine, root.jQuery); - } -}((function() {return this; })(), function (window, jasmine, $) { "use strict"; - - jasmine.spiedEventsKey = function (selector, eventName) { - return [$(selector).selector, eventName].toString() - } - - jasmine.getFixtures = function () { - return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures() - } - - jasmine.getStyleFixtures = function () { - return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures() - } - - jasmine.Fixtures = function () { - this.containerId = 'jasmine-fixtures' - this.fixturesCache_ = {} - this.fixturesPath = 'spec/javascripts/fixtures' - } - - jasmine.Fixtures.prototype.set = function (html) { - this.cleanUp() - return this.createContainer_(html) - } - - jasmine.Fixtures.prototype.appendSet= function (html) { - this.addToContainer_(html) - } - - jasmine.Fixtures.prototype.preload = function () { - this.read.apply(this, arguments) - } - - jasmine.Fixtures.prototype.load = function () { - this.cleanUp() - this.createContainer_(this.read.apply(this, arguments)) - } - - jasmine.Fixtures.prototype.appendLoad = function () { - this.addToContainer_(this.read.apply(this, arguments)) - } - - jasmine.Fixtures.prototype.read = function () { - var htmlChunks = [] - , fixtureUrls = arguments - - for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { - htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex])) - } - - return htmlChunks.join('') - } - - jasmine.Fixtures.prototype.clearCache = function () { - this.fixturesCache_ = {} - } - - jasmine.Fixtures.prototype.cleanUp = function () { - $('#' + this.containerId).remove() - } - - jasmine.Fixtures.prototype.sandbox = function (attributes) { - var attributesToSet = attributes || {} - return $('
').attr(attributesToSet) - } - - jasmine.Fixtures.prototype.createContainer_ = function (html) { - var container = $('
') - .attr('id', this.containerId) - .html(html) - - $(document.body).append(container) - return container - } - - jasmine.Fixtures.prototype.addToContainer_ = function (html){ - var container = $(document.body).find('#'+this.containerId).append(html) - - if (!container.length) { - this.createContainer_(html) - } - } - - jasmine.Fixtures.prototype.getFixtureHtml_ = function (url) { - if (typeof this.fixturesCache_[url] === 'undefined') { - this.loadFixtureIntoCache_(url) - } - return this.fixturesCache_[url] - } - - jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { - var self = this - , url = this.makeFixtureUrl_(relativeUrl) - , htmlText = '' - , request = $.ajax({ - async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded - cache: false, - url: url, - dataType: 'html', - success: function (data, status, $xhr) { - htmlText = $xhr.responseText - } - }).fail(function ($xhr, status, err) { - throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')') - }) - - var scripts = $($.parseHTML(htmlText, true)).find('script[src]') || []; - - scripts.each(function(){ - $.ajax({ - async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded - cache: false, - dataType: 'script', - url: $(this).attr('src'), - success: function (data, status, $xhr) { - htmlText += '' - }, - error: function ($xhr, status, err) { - throw new Error('Script could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')') - } - }); - }) - - self.fixturesCache_[relativeUrl] = htmlText; - } - - jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){ - return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl - } - - jasmine.Fixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) { - return this[methodName].apply(this, passedArguments) - } - - - jasmine.StyleFixtures = function () { - this.fixturesCache_ = {} - this.fixturesNodes_ = [] - this.fixturesPath = 'spec/javascripts/fixtures' - } - - jasmine.StyleFixtures.prototype.set = function (css) { - this.cleanUp() - this.createStyle_(css) - } - - jasmine.StyleFixtures.prototype.appendSet = function (css) { - this.createStyle_(css) - } - - jasmine.StyleFixtures.prototype.preload = function () { - this.read_.apply(this, arguments) - } - - jasmine.StyleFixtures.prototype.load = function () { - this.cleanUp() - this.createStyle_(this.read_.apply(this, arguments)) - } - - jasmine.StyleFixtures.prototype.appendLoad = function () { - this.createStyle_(this.read_.apply(this, arguments)) - } - - jasmine.StyleFixtures.prototype.cleanUp = function () { - while(this.fixturesNodes_.length) { - this.fixturesNodes_.pop().remove() - } - } - - jasmine.StyleFixtures.prototype.createStyle_ = function (html) { - var styleText = $('
').html(html).text() - , style = $('') - - this.fixturesNodes_.push(style) - $('head').append(style) - } - - jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache - jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read - jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_ - jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_ - jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_ - jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_ - - jasmine.getJSONFixtures = function () { - return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures() - } - - jasmine.JSONFixtures = function () { - this.fixturesCache_ = {} - this.fixturesPath = 'spec/javascripts/fixtures/json' - } - - jasmine.JSONFixtures.prototype.load = function () { - this.read.apply(this, arguments) - return this.fixturesCache_ - } - - jasmine.JSONFixtures.prototype.read = function () { - var fixtureUrls = arguments - - for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) { - this.getFixtureData_(fixtureUrls[urlIndex]) - } - - return this.fixturesCache_ - } - - jasmine.JSONFixtures.prototype.clearCache = function () { - this.fixturesCache_ = {} - } - - jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) { - if (!this.fixturesCache_[url]) this.loadFixtureIntoCache_(url) - return this.fixturesCache_[url] - } - - jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) { - var self = this - , url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl - - $.ajax({ - async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded - cache: false, - dataType: 'json', - url: url, - success: function (data) { - self.fixturesCache_[relativeUrl] = data - }, - error: function ($xhr, status, err) { - throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + err.message + ')') - } - }) - } - - jasmine.JSONFixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) { - return this[methodName].apply(this, passedArguments) - } - - jasmine.jQuery = function () {} - - jasmine.jQuery.browserTagCaseIndependentHtml = function (html) { - return $('
').append(html).html() - } - - jasmine.jQuery.elementToString = function (element) { - return $(element).map(function () { return this.outerHTML; }).toArray().join(', ') - } - - var data = { - spiedEvents: {} - , handlers: [] - } - - jasmine.jQuery.events = { - spyOn: function (selector, eventName) { - var handler = function (e) { - var calls = (typeof data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] !== 'undefined') ? data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : 0 - data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = { - args: jasmine.util.argsToArray(arguments), - calls: ++calls - } - } - - $(selector).on(eventName, handler) - data.handlers.push(handler) - - return { - selector: selector, - eventName: eventName, - handler: handler, - reset: function (){ - delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - }, - calls: { - count: function () { - return data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] ? - data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : 0; - }, - any: function () { - return data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] ? - !!data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].calls : false; - } - } - } - }, - - args: function (selector, eventName) { - var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].args - - if (!actualArgs) { - throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent." - } - - return actualArgs - }, - - wasTriggered: function (selector, eventName) { - return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]) - }, - - wasTriggeredWith: function (selector, eventName, expectedArgs, util, customEqualityTesters) { - var actualArgs = jasmine.jQuery.events.args(selector, eventName).slice(1) - - if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') - actualArgs = actualArgs[0] - - return util.equals(actualArgs, expectedArgs, customEqualityTesters) - }, - - wasPrevented: function (selector, eventName) { - var spiedEvent = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - , args = (jasmine.util.isUndefined(spiedEvent)) ? {} : spiedEvent.args - , e = args ? args[0] : undefined - - return e && e.isDefaultPrevented() - }, - - wasStopped: function (selector, eventName) { - var spiedEvent = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] - , args = (jasmine.util.isUndefined(spiedEvent)) ? {} : spiedEvent.args - , e = args ? args[0] : undefined - - return e && e.isPropagationStopped() - }, - - cleanUp: function () { - data.spiedEvents = {} - data.handlers = [] - } - } - - var hasProperty = function (actualValue, expectedValue) { - if (expectedValue === undefined) - return actualValue !== undefined - - return actualValue === expectedValue - } - - beforeEach(function () { - jasmine.addMatchers({ - toHaveClass: function () { - return { - compare: function (actual, className) { - return { pass: $(actual).hasClass(className) } - } - } - }, - - toHaveCss: function () { - return { - compare: function (actual, css) { - var stripCharsRegex = /[\s;\"\']/g - for (var prop in css) { - var value = css[prop] - // see issue #147 on gh - ;if ((value === 'auto') && ($(actual).get(0).style[prop] === 'auto')) continue - var actualStripped = $(actual).css(prop).replace(stripCharsRegex, '') - var valueStripped = value.replace(stripCharsRegex, '') - if (actualStripped !== valueStripped) return { pass: false } - } - return { pass: true } - } - } - }, - - toBeVisible: function () { - return { - compare: function (actual) { - return { pass: $(actual).is(':visible') } - } - } - }, - - toBeHidden: function () { - return { - compare: function (actual) { - return { pass: $(actual).is(':hidden') } - } - } - }, - - toBeSelected: function () { - return { - compare: function (actual) { - return { pass: $(actual).is(':selected') } - } - } - }, - - toBeChecked: function () { - return { - compare: function (actual) { - return { pass: $(actual).is(':checked') } - } - } - }, - - toBeEmpty: function () { - return { - compare: function (actual) { - return { pass: $(actual).is(':empty') } - } - } - }, - - toBeInDOM: function () { - return { - compare: function (actual) { - return { pass: $.contains(document.documentElement, $(actual)[0]) } - } - } - }, - - toExist: function () { - return { - compare: function (actual) { - return { pass: $(actual).length } - } - } - }, - - toHaveLength: function () { - return { - compare: function (actual, length) { - return { pass: $(actual).length === length } - } - } - }, - - toHaveAttr: function () { - return { - compare: function (actual, attributeName, expectedAttributeValue) { - return { pass: hasProperty($(actual).attr(attributeName), expectedAttributeValue) } - } - } - }, - - toHaveProp: function () { - return { - compare: function (actual, propertyName, expectedPropertyValue) { - return { pass: hasProperty($(actual).prop(propertyName), expectedPropertyValue) } - } - } - }, - - toHaveId: function () { - return { - compare: function (actual, id) { - return { pass: $(actual).attr('id') == id } - } - } - }, - - toHaveHtml: function () { - return { - compare: function (actual, html) { - return { pass: $(actual).html() == jasmine.jQuery.browserTagCaseIndependentHtml(html) } - } - } - }, - - toContainHtml: function () { - return { - compare: function (actual, html) { - var actualHtml = $(actual).html() - , expectedHtml = jasmine.jQuery.browserTagCaseIndependentHtml(html) - - return { pass: (actualHtml.indexOf(expectedHtml) >= 0) } - } - } - }, - - toHaveText: function () { - return { - compare: function (actual, text) { - var actualText = $(actual).text() - var trimmedText = $.trim(actualText) - - if (text && $.isFunction(text.test)) { - return { pass: text.test(actualText) || text.test(trimmedText) } - } else { - return { pass: (actualText == text || trimmedText == text) } - } - } - } - }, - - toContainText: function () { - return { - compare: function (actual, text) { - var trimmedText = $.trim($(actual).text()) - - if (text && $.isFunction(text.test)) { - return { pass: text.test(trimmedText) } - } else { - return { pass: trimmedText.indexOf(text) != -1 } - } - } - } - }, - - toHaveValue: function () { - return { - compare: function (actual, value) { - return { pass: $(actual).val() === value } - } - } - }, - - toHaveData: function () { - return { - compare: function (actual, key, expectedValue) { - return { pass: hasProperty($(actual).data(key), expectedValue) } - } - } - }, - - toContainElement: function () { - return { - compare: function (actual, selector) { - return { pass: $(actual).find(selector).length } - } - } - }, - - toBeMatchedBy: function () { - return { - compare: function (actual, selector) { - return { pass: $(actual).filter(selector).length } - } - } - }, - - toBeDisabled: function () { - return { - compare: function (actual, selector) { - return { pass: $(actual).is(':disabled') } - } - } - }, - - toBeFocused: function (selector) { - return { - compare: function (actual, selector) { - return { pass: $(actual)[0] === $(actual)[0].ownerDocument.activeElement } - } - } - }, - - toHandle: function () { - return { - compare: function (actual, event) { - if ( !actual || actual.length === 0 ) return { pass: false }; - var events = $._data($(actual).get(0), "events") - - if (!events || !event || typeof event !== "string") { - return { pass: false } - } - - var namespaces = event.split(".") - , eventType = namespaces.shift() - , sortedNamespaces = namespaces.slice(0).sort() - , namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") - - if (events[eventType] && namespaces.length) { - for (var i = 0; i < events[eventType].length; i++) { - var namespace = events[eventType][i].namespace - - if (namespaceRegExp.test(namespace)) - return { pass: true } - } - } else { - return { pass: (events[eventType] && events[eventType].length > 0) } - } - - return { pass: false } - } - } - }, - - toHandleWith: function () { - return { - compare: function (actual, eventName, eventHandler) { - if ( !actual || actual.length === 0 ) return { pass: false }; - var normalizedEventName = eventName.split('.')[0] - , stack = $._data($(actual).get(0), "events")[normalizedEventName] - - for (var i = 0; i < stack.length; i++) { - if (stack[i].handler == eventHandler) return { pass: true } - } - - return { pass: false } - } - } - }, - - toHaveBeenTriggeredOn: function () { - return { - compare: function (actual, selector) { - var result = { pass: jasmine.jQuery.events.wasTriggered(selector, actual) } - - result.message = result.pass ? - "Expected event " + $(actual) + " not to have been triggered on " + selector : - "Expected event " + $(actual) + " to have been triggered on " + selector - - return result; - } - } - }, - - toHaveBeenTriggered: function (){ - return { - compare: function (actual) { - var eventName = actual.eventName - , selector = actual.selector - , result = { pass: jasmine.jQuery.events.wasTriggered(selector, eventName) } - - result.message = result.pass ? - "Expected event " + eventName + " not to have been triggered on " + selector : - "Expected event " + eventName + " to have been triggered on " + selector - - return result - } - } - }, - - toHaveBeenTriggeredOnAndWith: function (j$, customEqualityTesters) { - return { - compare: function (actual, selector, expectedArgs) { - var wasTriggered = jasmine.jQuery.events.wasTriggered(selector, actual) - , result = { pass: wasTriggered && jasmine.jQuery.events.wasTriggeredWith(selector, actual, expectedArgs, j$, customEqualityTesters) } - - if (wasTriggered) { - var actualArgs = jasmine.jQuery.events.args(selector, actual, expectedArgs)[1] - result.message = result.pass ? - "Expected event " + actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) : - "Expected event " + actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs) - - } else { - // todo check on this - result.message = result.pass ? - "Expected event " + actual + " not to have been triggered on " + selector : - "Expected event " + actual + " to have been triggered on " + selector - } - - return result - } - } - }, - - toHaveBeenPreventedOn: function () { - return { - compare: function (actual, selector) { - var result = { pass: jasmine.jQuery.events.wasPrevented(selector, actual) } - - result.message = result.pass ? - "Expected event " + actual + " not to have been prevented on " + selector : - "Expected event " + actual + " to have been prevented on " + selector - - return result - } - } - }, - - toHaveBeenPrevented: function () { - return { - compare: function (actual) { - var eventName = actual.eventName - , selector = actual.selector - , result = { pass: jasmine.jQuery.events.wasPrevented(selector, eventName) } - - result.message = result.pass ? - "Expected event " + eventName + " not to have been prevented on " + selector : - "Expected event " + eventName + " to have been prevented on " + selector - - return result - } - } - }, - - toHaveBeenStoppedOn: function () { - return { - compare: function (actual, selector) { - var result = { pass: jasmine.jQuery.events.wasStopped(selector, actual) } - - result.message = result.pass ? - "Expected event " + actual + " not to have been stopped on " + selector : - "Expected event " + actual + " to have been stopped on " + selector - - return result; - } - } - }, - - toHaveBeenStopped: function () { - return { - compare: function (actual) { - var eventName = actual.eventName - , selector = actual.selector - , result = { pass: jasmine.jQuery.events.wasStopped(selector, eventName) } - - result.message = result.pass ? - "Expected event " + eventName + " not to have been stopped on " + selector : - "Expected event " + eventName + " to have been stopped on " + selector - - return result - } - } - } - }) - - jasmine.getEnv().addCustomEqualityTester(function(a, b) { - if (a && b) { - if (a instanceof $ || jasmine.isDomNode(a)) { - var $a = $(a) - - if (b instanceof $) - return $a.length == b.length && a.is(b) - - return $a.is(b); - } - - if (b instanceof $ || jasmine.isDomNode(b)) { - var $b = $(b) - - if (a instanceof $) - return a.length == $b.length && $b.is(a) - - return $(b).is(a); - } - } - }) - - jasmine.getEnv().addCustomEqualityTester(function (a, b) { - if (a instanceof $ && b instanceof $ && a.size() == b.size()) - return a.is(b) - }) - }) - - afterEach(function () { - jasmine.getFixtures().cleanUp() - jasmine.getStyleFixtures().cleanUp() - jasmine.jQuery.events.cleanUp() - }) - - window.readFixtures = function () { - return jasmine.getFixtures().proxyCallTo_('read', arguments) - } - - window.preloadFixtures = function () { - jasmine.getFixtures().proxyCallTo_('preload', arguments) - } - - window.loadFixtures = function () { - jasmine.getFixtures().proxyCallTo_('load', arguments) - } - - window.appendLoadFixtures = function () { - jasmine.getFixtures().proxyCallTo_('appendLoad', arguments) - } - - window.setFixtures = function (html) { - return jasmine.getFixtures().proxyCallTo_('set', arguments) - } - - window.appendSetFixtures = function () { - jasmine.getFixtures().proxyCallTo_('appendSet', arguments) - } - - window.sandbox = function (attributes) { - return jasmine.getFixtures().sandbox(attributes) - } - - window.spyOnEvent = function (selector, eventName) { - return jasmine.jQuery.events.spyOn(selector, eventName) - } - - window.preloadStyleFixtures = function () { - jasmine.getStyleFixtures().proxyCallTo_('preload', arguments) - } - - window.loadStyleFixtures = function () { - jasmine.getStyleFixtures().proxyCallTo_('load', arguments) - } - - window.appendLoadStyleFixtures = function () { - jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments) - } - - window.setStyleFixtures = function (html) { - jasmine.getStyleFixtures().proxyCallTo_('set', arguments) - } - - window.appendSetStyleFixtures = function (html) { - jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments) - } - - window.loadJSONFixtures = function () { - return jasmine.getJSONFixtures().proxyCallTo_('load', arguments) - } - - window.getJSONFixture = function (url) { - return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url] - } -})); \ No newline at end of file diff --git a/spec/javascripts/helpers/key-press.js b/spec/javascripts/helpers/key-press.js deleted file mode 100644 index 869f4ef8e1..0000000000 --- a/spec/javascripts/helpers/key-press.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = function(key) { - const event = jQuery.Event("keyup"); - event.which = key; - event.keyCode = key; - $(document).trigger(event); -}; diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml deleted file mode 100644 index 7bfb241582..0000000000 --- a/spec/javascripts/support/jasmine.yml +++ /dev/null @@ -1,135 +0,0 @@ -# src_files -# -# Return an array of filepaths relative to src_dir to include before jasmine specs. -# Default: [] -# -# EXAMPLE: -# -# src_files: -# - lib/source1.js -# - lib/source2.js -# - dist/**/*.js -# -src_files: - - assets/application.js - -# stylesheets -# -# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs. -# Default: [] -# -# EXAMPLE: -# -# stylesheets: -# - css/style.css -# - stylesheets/*.css -# -stylesheets: - - assets/application.css - -# helpers -# -# Return an array of filepaths relative to spec_dir to include before jasmine specs. -# Default: ["helpers/**/*.js"] -# -# EXAMPLE: -# -# helpers: -# - helpers/**/*.js -# -helpers: - - 'helpers/**/*.js' - -# spec_files -# -# Return an array of filepaths relative to spec_dir to include. -# Default: ["**/*[sS]pec.js"] -# -# EXAMPLE: -# -# spec_files: -# - **/*[sS]pec.js -# -spec_files: - - '**/*[sS]pec.js' - -# src_dir -# -# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank. -# Default: project root -# -# EXAMPLE: -# -# src_dir: public -# -src_dir: - -# spec_dir -# -# Spec directory path. Your spec_files must be returned relative to this path. -# Default: spec/javascripts -# -# EXAMPLE: -# -# spec_dir: spec/javascripts -# -spec_dir: - -# spec_helper -# -# Ruby file that Jasmine server will require before starting. -# Returned relative to your root path -# Default spec/javascripts/support/jasmine_helper.rb -# -# EXAMPLE: -# -# spec_helper: spec/javascripts/support/jasmine_helper.rb -# -spec_helper: spec/javascripts/support/jasmine_helper.rb - -# boot_dir -# -# Boot directory path. Your boot_files must be returned relative to this path. -# Default: Built in boot file -# -# EXAMPLE: -# -# boot_dir: spec/javascripts/support/boot -# -boot_dir: - -# boot_files -# -# Return an array of filepaths relative to boot_dir to include in order to boot Jasmine -# Default: Built in boot file -# -# EXAMPLE -# -# boot_files: -# - '**/*.js' -# -boot_files: - -# rack_options -# -# Extra options to be passed to the rack server -# by default, Port and AccessLog are passed. -# -# This is an advanced options, and left empty by default -# -# EXAMPLE -# -# rack_options: -# server: 'thin' - -# random -# -# Run specs in semi-random order. -# Default: false -# -# EXAMPLE: -# -# random: true -# -random: - diff --git a/spec/javascripts/support/jasmine_helper.rb b/spec/javascripts/support/jasmine_helper.rb deleted file mode 100644 index dea455e6ee..0000000000 --- a/spec/javascripts/support/jasmine_helper.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -# Use this file to set/override Jasmine configuration options -# You can remove it if you don't need it. -# This file is loaded *after* jasmine.yml is interpreted. -# -# Example: using a different boot file. -# Jasmine.configure do |config| -# config.boot_dir = '/absolute/path/to/boot_dir' -# config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] } -# end -# -# Example: prevent PhantomJS auto install, uses PhantomJS already on your path. -Jasmine.configure do |config| - config.prevent_phantom_js_auto_install = true -end