...The AJAX call is asynchronously and we don't have control over when it returns (and hence when it calls the callback function). Here is a test that does all...

We're using jasmine-ajax to mock access to the network. jasmine.Ajax.requests.mostRecent() returns the most recent AJAX request, which we can inspect for its parameters and payload. We...

developer.mozilla.org

You can easily have a JavaScript hash/object that returns a default value for unset keys/properties -- as long as you need to support only recent browsers. The key are JavaScript proxies...

...getter method. They work like this: var hash = new Proxy({}, { get: function(object, property) { return object.hasOwnProperty(property) ? object[property] : 'hello'; } }); When you set a key, you can read its value...

makandra dev
select2.org

"more": true } } Basic ajax options $('#mySelect2').select2({ ajax: { url: , data: function (params) { return { query: params.term, page: params.page || 1 } } processResults: function (data, params) { return data }, } }); Further reading: https://select2.org/data-sources/ajax

docs.gitlab.com

...the same job. If you configure one job to use both keywords, the linter returns a key may not be used with rules error. GitLab 12.3 introduced rules. You can...

Consider you have a website vhost listening to www.example.com, redirecting all incoming requests that do not talk about the configured...

...var container = $.find('.container', document.body)[0]; var openTasks = $.find('.task.open', container); Note that Sizzle returns vanilla DOM nodes in a vanilla Javascript array. It does not return jQuery collections...

...child of the element we're checking var candidateFromPoint = $(elementFromPoint).closest(elementFromSelector).get(0); return elementFromSelector == candidateFromPoint; JS is_top_element = page.execute_script(js) expect(is_top_element).to eq...

...for(locator) method, which takes a prose locator like "the very important notice" and returns a CSS selector like .very-important-notice. If you are using Spreewald, this method is...

...requests for every page. The browser will first request /foo, then the server will return a redirect to /foo/ (mind the trailing slash), then the browser makes a second request...

...by configuring your static web server. What we want is: Accessing /foo should directly return the content of /foo/index.html without a redirect Accessing /foo/ should redirect to the canonical /foo...

angular-tips.com

...app.factory('name', someFunction) someFunction is called when the name service is instantiated and should return an object Service just like Factory, but: instead of a funciton, it receives a Javascript...

^ app.config(function($provide) { $provide.decorator('serviceToBeDecorated', function($delegate) { // modify $delegate by adding functions etc. return $delegate; }); }); More differences | | Factory | Service | Value | Constant | Provider | | can have dependencies | yes | yes | no | no...

...useful methods: URLSearchParams.append() - appends a query parameter URLSearchParams.delete() - deletes the specified query parameter URLSearchParams.get() - returns the value of the specified query parameter URLSearchParams.has() - checks if specified query parameter exists URLSearchParams.set...

...for RSpec users: |---------------------------------------------------------| | RSpec | Mocha | |---------------------------------------------------------| | obj = double() | obj = mock() | | obj.stub(:method => 'value') | obj.stubs(:method).returns('value') | | obj.should_receive(:method).with('argument').and_return('value') | obj.expects(:method).with('argument').returns('value...

...Sass function is computing a result that is neither assigned to a variable nor returned. Keep in mind that all functions in Sass return something, Sass does not mutate objects...

makandra dev

...below gives you just that. // Call with two desired values at two different widths. // Returns a calc() expression that will scale proportionally between those two. // Example: // Spacing should be 15px...

$width2 * $relative + $static = $spacing2 $relative: ($spacing2 - $spacing1) / ($width2 - $width1) $static: $spacing1 - ($width1 * $relative) @return calc(#{$relative * 100%} + #{$static * 1px...

...the element "([^\"]+)" should( not)? have scrollbars$/ do |selector, no_scrollbars| scroll_height = page.execute_script("return $('#{selector}').get(0).scrollHeight;") offset_height = page.execute_script("return $('#{selector}').get(0).offsetHeight;") comparison = no...

...get: () => value, set: (newValue) => value = newValue } delete newDescriptor.value delete newDescriptor.writable Object.defineProperty(obj, prop, newDescriptor) return spyOnProperty(obj, prop, accessType...

should include the model and tag if the tool has a tag should return the model if the tool has no tag .search should find tools by model and...

blog.jayfields.com

...legacy code. For new code, always use capture3. %x{ } or backticks – quick and easy Returns the standard output of running the given command in a subshell. This is an alias...

...exec, but executes the given command in a subshell. Your script will go on. Returns: true if the command gives zero exit status false for non zero exit status

...is some plain JavaScript, should you prefer that: function joinSentence(array) { if (array.length > 1) { return array.slice(0, -1).join(', ') + ', and ' + array.slice(-1); } else { return array.join...

...extra attribute) you might run into trouble when submitting the form by pressing the return key in a field. When nothing fancy like a tabindex is defined it seems as...

...submit element inside a form is chosen (and has its attributes submitted) when pressing return.\ So, if possible, put your "default" (aka least harmful) submit element before others.

...attr_writer :browser_died def scenario_started self.browser_died = false end def scenario_ended return unless session.driver.is_a?(::Capybara::Selenium::Driver) self.driver_scenario_count += 1 if !browser_died? && driver_scenario...

makandra dev

...image_tag), Rails will compile your entire assets within its process before that helper returns. This will cause your helper to freeze for many seconds. Since Webpack needs to boot...

ls -1tr * | tail -1 Used switches The -1 switch makes ls return 1 file per line, -t orders by modification time and -r causes sorting from oldest...

...to newest. tail -1 then returns the last line, containing the newest file's name. If you require only a subset of files, adjust the "*" mask accordingly or use other...

...Laden von Models passieren # search_spec.rb describe Search, search: true do # enable indexing # ... it 'only returns posts for a post query' do post = create(:post) create(:event) Post.search_index.refresh # force index to...

edgeapi.rubyonrails.org

# or b.label(class: "my-#{ b.object.class.name.parameterize }", 'data-value': b.value) { b.check_box + b.text } end The return values of each call will be joined and returned. You may of course render HTML...