jquery/test/node_smoke_tests/lib/ensure_iterability_es6.js
Michał Gołębiowski-Owczarek 9cb124ed00
Build: Update jsdom; migrate a test with Symbol polyfill to an iframe test
So far, we've been testing that jQuery element iteration works with polyfilled
Symbol & transpiled for-of via a Node test with jsdom with the Symbol global
removed. Unfortunately, jsdom now requires Symbol to be present for its internal
functionality so such a test is no longer possible. Instead, it's been migrated
to an iframe test with transpiled JavaScript.

This PR also enables us to use ECMAScript 2017 or newer in Node.js code.

Closes gh-4305
2019-03-04 18:30:51 +01:00

26 lines
558 B
JavaScript

"use strict";
const assert = require( "assert" );
const ensureIterability = () => {
const { JSDOM } = require( "jsdom" );
const { window } = new JSDOM( "" );
let i;
const ensureJQuery = require( "./ensure_jquery" );
const jQuery = require( "../../../dist/jquery.js" )( window );
const elem = jQuery( "<div></div><span></span><a></a>" );
let result = "";
ensureJQuery( jQuery );
for ( i of elem ) {
result += i.nodeName;
}
assert.strictEqual( result, "DIVSPANA", "for-of works on jQuery objects" );
};
module.exports = ensureIterability;