inital
This commit is contained in:
329
node_modules/parse-srcset/tests/he.js
generated
vendored
Executable file
329
node_modules/parse-srcset/tests/he.js
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
74
node_modules/parse-srcset/tests/intern.js
generated
vendored
Normal file
74
node_modules/parse-srcset/tests/intern.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
// Learn more about configuring this file at
|
||||
// <https://github.com/theintern/intern/wiki/Configuring-Intern>.
|
||||
// These default settings work OK for most people. The options that *must* be
|
||||
// changed below are the packages, suites, excludeInstrumentation, and (if you
|
||||
// want functional tests) functionalSuites.
|
||||
|
||||
define({
|
||||
// The port on which the instrumenting proxy will listen
|
||||
proxyPort: 9000,
|
||||
|
||||
// A fully qualified URL to the Intern proxy
|
||||
proxyUrl: 'http://localhost:9000/',
|
||||
|
||||
// Default desired capabilities for all environments. Individual capabilities
|
||||
// can be overridden by any of the specified browser environments in the
|
||||
// `environments` array below as well. See
|
||||
// https://code.google.com/p/selenium/wiki/DesiredCapabilities
|
||||
// for standard Selenium capabilities and
|
||||
// https://saucelabs.com/docs/additional-config#desired-capabilities
|
||||
// for Sauce Labs capabilities.
|
||||
// Note that the `build` capability will be filled in with the current commit
|
||||
// ID from the Travis CI environment
|
||||
// automatically
|
||||
capabilities: {
|
||||
'selenium-version': '2.41.0'
|
||||
},
|
||||
|
||||
// Browsers to run integration testing against. Note that version numbers must
|
||||
// be strings if used with Sauce OnDemand. Options that will be permutated are
|
||||
// browserName, version, platform, and platformVersion; any other capabilities
|
||||
// options specified for an environment will be copied as-is.
|
||||
environments: [
|
||||
{ browserName: 'internet explorer', version: '11', platform: 'Windows 8.1' },
|
||||
{ browserName: 'internet explorer', version: '10', platform: 'Windows 8' },
|
||||
{ browserName: 'internet explorer', version: '9', platform: 'Windows 7' },
|
||||
{ browserName: 'firefox', version: '28', platform: [ 'OS X 10.9', 'Windows 7', 'Linux' ] },
|
||||
{ browserName: 'chrome', version: '34', platform: [ 'OS X 10.9', 'Windows 7', 'Linux' ] },
|
||||
{ browserName: 'safari', version: '6', platform: 'OS X 10.8' },
|
||||
{ browserName: 'safari', version: '7', platform: 'OS X 10.9' }
|
||||
],
|
||||
|
||||
// Maximum number of simultaneous integration tests that should be executed on
|
||||
// the remote WebDriver service.
|
||||
maxConcurrency: 3,
|
||||
|
||||
// Name of the tunnel class to use for WebDriver tests
|
||||
tunnel: 'SauceLabsTunnel',
|
||||
|
||||
// The desired AMD loader to use when running unit tests (client.html/client.js).
|
||||
// Omit to use the default Dojo loader.
|
||||
useLoader: {
|
||||
'host-node': 'dojo/dojo',
|
||||
'host-browser': 'node_modules/dojo/dojo.js'
|
||||
},
|
||||
|
||||
// Configuration options for the module loader; any AMD configuration options
|
||||
// supported by the specified AMD loader can be used here.
|
||||
loader: {
|
||||
// Packages that should be registered with the loader in each testing environment
|
||||
packages: [
|
||||
{ name: 'app', location: 'src/' },
|
||||
{ name: 'tests', location: 'tests/' }
|
||||
]
|
||||
},
|
||||
|
||||
// Non-functional test suite(s) to run in each browser
|
||||
suites: [ 'tests/unit/ps' ],
|
||||
|
||||
// Functional test suite(s) to run in each browser once non-functional tests are completed
|
||||
functionalSuites: [ /* 'myPackage/tests/functional' */ ],
|
||||
|
||||
// A regular expression matching URLs to files that should not be included in code coverage analysis
|
||||
excludeInstrumentation: /^(?:tests|node_modules)\//
|
||||
});
|
345
node_modules/parse-srcset/tests/unit/ps.js
generated
vendored
Normal file
345
node_modules/parse-srcset/tests/unit/ps.js
generated
vendored
Normal file
@@ -0,0 +1,345 @@
|
||||
define(function (require) {
|
||||
var tdd = require('intern!tdd');
|
||||
|
||||
// Not really Chai but a Chai-compatible "assert" library for old IE.
|
||||
var assert = require('intern/chai!assert');
|
||||
|
||||
// parse-srcset is an AMD module.
|
||||
var parseSrcset = require('../../src/parse-srcset');
|
||||
|
||||
var he = require('tests/he');
|
||||
|
||||
tdd.suite('Parse Srcset', function() {
|
||||
|
||||
// Adapted from the W3C srcset conformance checker at:
|
||||
// http://w3c-test.org/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html
|
||||
var w3Ctests = [
|
||||
{
|
||||
groupName: "Splitting Loop",
|
||||
testArray: [
|
||||
{srcset: '', expect: '', desc: 'empty string'},
|
||||
{srcset: ',' , expect: '', desc: 'single comma'},
|
||||
{srcset: ',,,', expect: '', desc: 'three commas'},
|
||||
{srcset: '		data:,a		1x		', expect: 'data:,a', desc: 'tabs'},
|
||||
{srcset: '

data:,a

1x

', expect: 'data:,a', desc: 'line feeds'},
|
||||
{srcset: 'data:,a1x', expect: 'data:,a1x', desc: 'line tab'},
|
||||
{srcset: 'data:,a1x', expect: 'data:,a', desc: 'form feed U+000C'},
|
||||
{srcset: '

data:,a

1x

', expect: 'data:,a', desc: 'carriage return U+000D'},
|
||||
{srcset: 'data:,a1x', expect: 'data:,a1x', desc: 'shift out U+000E'},
|
||||
{srcset: 'data:,a1x', expect: 'data:,a1x', desc: 'shift in U+000F' },
|
||||
{srcset: 'data:,a1x', expect: 'data:,a1x', desc: 'data link escape U+0010' },
|
||||
{srcset: 'data:,a', expect: 'data:,a', desc:'plain url'},
|
||||
{srcset: 'data:,a ', expect: 'data:,a', desc:'trailing space'},
|
||||
{srcset: 'data:,a ,', expect: 'data:,a', desc:'trailing space and comma'},
|
||||
{srcset: 'data:,a,', expect: 'data:,a', desc:'trailing comma'},
|
||||
{srcset: 'data:,a, ', expect: 'data:,a', desc:'trailing comma and space'},
|
||||
{srcset: 'data:,a,,,', expect: 'data:,a', desc:'trailing three commas'},
|
||||
{srcset: 'data:,a,, , ', expect: 'data:,a', desc:'trailing two commas space comma space'},
|
||||
{srcset: ' data:,a', expect: 'data:,a', desc:'leading space'},
|
||||
{srcset: ',,,data:,a', expect: 'data:,a', desc:'leading three commas'},
|
||||
{srcset: ' , ,,data:,a', expect: 'data:,a', desc:'leading space comma space comma comma'},
|
||||
{srcset: ' data:,a', expect: ' data:,a', desc:'leading non-breaking space'},
|
||||
{srcset: 'data:,a ', expect: 'data:,a ', desc:'trailing non-breaking space'}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
groupName: "Descriptor Tokenizer",
|
||||
testArray: [
|
||||
{srcset: 'data:,a 1x', expect: 'data:,a', desc: 'plain url with descriptor'},
|
||||
{srcset: 'data:,a 1x ', expect: 'data:,a', desc: 'trailing space'},
|
||||
{srcset: 'data:,a 1x,', expect: 'data:,a', desc: 'trailing comma'},
|
||||
{srcset: 'data:,a ( , data:,b 1x, ), data:,c', expect: 'data:,c', desc: 'irregular parens 1'},
|
||||
{srcset: 'data:,a ((( , data:,b 1x, ), data:,c', expect: 'data:,c', desc: 'irregular parens 2'},
|
||||
{srcset: 'data:,a [ , data:,b 1x, ], data:,c', expect: 'data:,b', desc: 'brackets'},
|
||||
{srcset: 'data:,a { , data:,b 1x, }, data:,c', expect: 'data:,b', desc: 'braces'},
|
||||
{srcset: 'data:,a " , data:,b 1x, ", data:,c', expect: 'data:,b', desc: 'double quotes'},
|
||||
{srcset: 'data:,a \\,data:;\\,b, data:,c', expect: 'data:;\\,b', desc: 'backslashes'},
|
||||
{srcset: 'data:,a, data:,b (', expect: 'data:,a', desc: 'trailing unclosed paren'},
|
||||
{srcset: 'data:,a, data:,b ( ', expect: 'data:,a', desc: 'unclosed paren space'},
|
||||
{srcset: 'data:,a, data:,b (,', expect: 'data:,a', desc: 'unclosed paren comma'},
|
||||
{srcset: 'data:,a, data:,b (x', expect: 'data:,a', desc: 'unclosed paren x'},
|
||||
{srcset: 'data:,a, data:,b ()', expect: 'data:,a', desc: 'parens, no descriptor'},
|
||||
{srcset: 'data:,a (, data:,b', expect: '', desc: 'unclosed paren'},
|
||||
{srcset: 'data:,a /*, data:,b, data:,c */', expect: 'data:,b', desc: 'block comments'},
|
||||
{srcset: 'data:,a //, data:,b', expect: 'data:,b', desc: 'double slash like a comment'}
|
||||
]
|
||||
},
|
||||
|
||||
{ groupName: "Descriptor Parser",
|
||||
testArray : [
|
||||
{srcset: 'data:,a foo', expect: '', desc: 'trailing foo'},
|
||||
{srcset: 'data:,a foo foo', expect: '', desc: 'trailing foo foo'},
|
||||
{srcset: 'data:,a foo 1x', expect: '', desc: 'trailing foo 1x'},
|
||||
{srcset: 'data:,a foo 1x foo', expect: '', desc: 'trailing 1x foo'},
|
||||
{srcset: 'data:,a foo 1w', expect: '', desc: 'trailing foo 1w'},
|
||||
{srcset: 'data:,a foo 1w foo', expect: '', desc: 'trailing foo 1w foo'},
|
||||
{srcset: 'data:,a 1x 1x', expect: '', desc: 'two density descriptors'},
|
||||
{srcset: 'data:,a 1w 1w', expect: '', desc: 'two width descriptors'},
|
||||
{srcset: 'data:,a 1h 1h', expect: '', desc: 'two height descriptors'},
|
||||
{srcset: 'data:,a 1w 1x', expect: '', desc: 'width then density'},
|
||||
{srcset: 'data:,a 1x 1w', expect: '', desc: 'density then width'},
|
||||
{srcset: 'data:,a 1w 1h', expect: 'data:,a', desc: 'width then height'},
|
||||
{srcset: 'data:,a 1h 1w', expect: 'data:,a', desc: 'height then width'},
|
||||
{srcset: 'data:,a 1h 1x', expect: '', desc: 'height then density'},
|
||||
{srcset: 'data:,a 1h 1w 1x', expect: '', desc: 'height then width then density'},
|
||||
{srcset: 'data:,a 1x 1w 1h', expect: '', desc: 'density then width then height'},
|
||||
{srcset: 'data:,a 1h foo', expect: '', desc: 'trailing 1h foo'},
|
||||
{srcset: 'data:,a foo 1h', expect: '', desc: 'trailing foo 1h'},
|
||||
{srcset: 'data:,a 0w', expect: '', desc: 'zero width'},
|
||||
{srcset: 'data:,a -1w', expect: '', desc: 'negative width'},
|
||||
{srcset: 'data:,a 1w -1w', expect: '', desc: 'positive width, negative width'},
|
||||
{srcset: 'data:,a 1.0w', expect: '', desc: 'floating point width'},
|
||||
{srcset: 'data:,a 1w 1.0w', expect: '', desc: 'integer width, floating point width'},
|
||||
{srcset: 'data:,a 1e0w', expect: '', desc: 'exponent width'},
|
||||
{srcset: 'data:,a 1w 1e0w', expect: '', desc: 'integer width, exponent width'},
|
||||
{srcset: 'data:,a 1www', expect: '', desc: '1www'},
|
||||
{srcset: 'data:,a 1w 1www', expect: '', desc: '1w 1www'},
|
||||
{srcset: 'data:,a 1w +1w', expect: '', desc: '1w +1w'},
|
||||
{srcset: 'data:,a 1W', expect: '', desc: 'capital W descriptor'},
|
||||
{srcset: 'data:,a 1w 1W', expect: '', desc: 'lowercase w, capital W descriptors'},
|
||||
{srcset: 'data:,a Infinityw', expect: '', desc: 'Infinityw'},
|
||||
{srcset: 'data:,a 1w Infinityw', expect: '', desc: '1w Infinityw'},
|
||||
{srcset: 'data:,a NaNw', expect: '', desc: 'Nanw'},
|
||||
{srcset: 'data:,a 1w NaNw', expect: '', desc: '1w Nanw'},
|
||||
{srcset: 'data:,a 0x1w', expect: '', desc: 'ox1w'},
|
||||
{srcset: 'data:,a 1w', expect: '', desc: 'trailing U+0001'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+00A0'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+1680'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2000'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2001'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2002'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2003'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2004'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2005'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2006'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2007'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2008'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+2009'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+200A'},
|
||||
{srcset: 'data:,a 1‌w', expect: '', desc: 'trailing U+200C'},
|
||||
{srcset: 'data:,a 1‍w', expect: '', desc: 'trailing U+200D'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+202F'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+205F'},
|
||||
{srcset: 'data:,a 1 w', expect: '', desc: 'trailing U+3000'},
|
||||
{srcset: 'data:,a 1w', expect: '', desc: 'trailing U+FEFF'},
|
||||
{srcset: 'data:,a 1w' , expect: '', desc: 'leading U+0001'},
|
||||
// {srcset: 'data:,a 1w' , expect: '', desc: 'leading U+00A0 width'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+1680'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2000'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2001'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2002'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2003'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2004'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2005'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2006'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2007'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2008'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+2009'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+200A'},
|
||||
{srcset: 'data:,a ‌1w', expect: '', desc: 'leading U+200C'},
|
||||
{srcset: 'data:,a ‍1w', expect: '', desc: 'leading U+200D'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+202F'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+205F'},
|
||||
{srcset: 'data:,a  1w', expect: '', desc: 'leading U+3000'},
|
||||
{srcset: 'data:,a 1w', expect: '', desc: 'leading U+FEFF'},
|
||||
{srcset: 'data:,a 0x', expect: 'data:,a', desc: 'zero density'},
|
||||
{srcset: 'data:,a -0x' , expect: 'data:,a', desc: 'negative zero density'},
|
||||
{srcset: 'data:,a 1x -0x', expect: '', desc: '1x -0x'},
|
||||
{srcset: 'data:,a -1x', expect: '', desc: '-1x'},
|
||||
{srcset: 'data:,a 1x -1x', expect: '', desc: '1x -1x'},
|
||||
{srcset: 'data:,a 1e0x', expect: 'data:,a', desc: '1e0x'},
|
||||
{srcset: 'data:,a 1E0x', expect: 'data:,a', desc: '1E0x'},
|
||||
{srcset: 'data:,a 1e-1x', expect: 'data:,a', desc: '1e-1x'},
|
||||
{srcset: 'data:,a 1.5e1x', expect: 'data:,a', desc: '1.5e1x'},
|
||||
{srcset: 'data:,a -x', expect: '', desc: 'negative density with no digits'},
|
||||
{srcset: 'data:,a .x', expect: '', desc: 'decimal density with no digits'},
|
||||
{srcset: 'data:,a -.x', expect: '', desc: '-.x'},
|
||||
{srcset: 'data:,a 1.x', expect: '', desc: '1.x'},
|
||||
{srcset: 'data:,a .5x', expect: 'data:,a', desc: 'floating point density descriptor'},
|
||||
{srcset: 'data:,a .5e1x', expect: 'data:,a', desc: '.5e1x'},
|
||||
{srcset: 'data:,a 1x 1.5e1x', expect: '', desc: '1x 1.5e1x'},
|
||||
{srcset: 'data:,a 1x 1e1.5x', expect: '', desc: '1x 1e1.5x'},
|
||||
{srcset: 'data:,a 1.0x', expect: 'data:,a', desc: '1.0x'},
|
||||
{srcset: 'data:,a 1x 1.0x', expect: '', desc: '1x 1.0x'},
|
||||
{srcset: 'data:,a +1x', expect: '', desc: 'no plus sign allowed on floating point number'},
|
||||
{srcset: 'data:,a 1X', expect: '', desc: 'Capital X descriptor'},
|
||||
{srcset: 'data:,a Infinityx', expect: '', desc: 'Infinityx'},
|
||||
{srcset: 'data:,a NaNx', expect: '', desc: 'NaNx'},
|
||||
{srcset: 'data:,a 0x1x', expect: '', desc: '0X1x'},
|
||||
{srcset: 'data:,a 0X1x', expect: '', desc: '1x'},
|
||||
{srcset: 'data:,a 1x', expect: '', desc: 'trailing U+0001'},
|
||||
{srcset: 'data:,a 1 x' , expect: '', desc: 'trailing U+00A0 density'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+1680'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2000'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2001'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2002'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2003'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2004'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2005'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2006'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2007'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2008'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+2009'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+200A'},
|
||||
{srcset: 'data:,a 1‌x', expect: '', desc: 'trailing U+200C'},
|
||||
{srcset: 'data:,a 1‍x', expect: '', desc: 'trailing U+200D'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+202F'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+205F'},
|
||||
{srcset: 'data:,a 1 x', expect: '', desc: 'trailing U+3000'},
|
||||
{srcset: 'data:,a 1x', expect: '', desc: 'trailing U+FEFF'},
|
||||
{srcset: 'data:,a 1x' , expect: '', desc: 'leading U+0001'},
|
||||
{srcset: 'data:,a 1x' , expect: '', desc: 'leading U+00A0 density'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+1680'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2000'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2001'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2002'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2003'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2004'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2005'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2006'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2007'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2008'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+2009'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+200A'},
|
||||
{srcset: 'data:,a ‌1x', expect: '', desc: 'leading U+200C'},
|
||||
{srcset: 'data:,a ‍1x', expect: '', desc: 'leading U+200D'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+202F'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+205F'},
|
||||
{srcset: 'data:,a  1x', expect: '', desc: 'leading U+3000'},
|
||||
{srcset: 'data:,a 1x', expect: '', desc: 'leading U+FEFF'},
|
||||
{srcset: 'data:,a 1w 0h', expect: '', desc: '1w 0h'},
|
||||
{srcset: 'data:,a 1w -1h', expect: '', desc: '1w -1h'},
|
||||
{srcset: 'data:,a 1w 1.0h', expect: '', desc: '1w 1.0h'},
|
||||
{srcset: 'data:,a 1w 1e0h', expect: '', desc: '1w 1e0h'},
|
||||
{srcset: 'data:,a 1w 1hhh', expect: '', desc: '1w 1hhh'},
|
||||
{srcset: 'data:,a 1w 1H', expect: '', desc: '1w 1H'},
|
||||
{srcset: 'data:,a 1w Infinityh', expect: '', desc: '1w Infinityh'},
|
||||
{srcset: 'data:,a 1w NaNh', expect: '', desc: '1w NaNh'},
|
||||
{srcset: 'data:,a 0x1h', expect: '', desc: '0x1h'},
|
||||
{srcset: 'data:,a 0X1h', expect: '', desc: '0X1h'},
|
||||
{srcset: 'data:,a 1w 1h', expect: '', desc: 'trailing U+0001'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+00A0'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+1680'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2000'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2001'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2002'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2003'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2004'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2005'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2006'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2007'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2008'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+2009'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+200A'},
|
||||
{srcset: 'data:,a 1w 1‌h', expect: '', desc: 'trailing U+200C'},
|
||||
{srcset: 'data:,a 1w 1‍h', expect: '', desc: 'trailing U+200D'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+202F'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+205F'},
|
||||
{srcset: 'data:,a 1w 1 h', expect: '', desc: 'trailing U+3000'},
|
||||
{srcset: 'data:,a 1w 1h', expect: '', desc: 'trailing U+FEFF'},
|
||||
{srcset: 'data:,a 1w 1h', expect: '', desc: 'leading U+0001'},
|
||||
{srcset: 'data:,a 1w 1h', expect: '', desc: 'leading U+00A0'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+1680'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2000'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2001'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2002'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2003'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2004'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2005'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2006'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2007'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2008'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+2009'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+200A'},
|
||||
{srcset: 'data:,a 1w ‌1h', expect: '', desc: 'leading U+200C'},
|
||||
{srcset: 'data:,a 1w ‍1h', expect: '', desc: 'leading U+200D'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+202F'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+205F'},
|
||||
{srcset: 'data:,a 1w  1h', expect: '', desc: 'leading U+3000'},
|
||||
{srcset: 'data:,a 1w 1h', expect: '', desc: 'leading U+FEFF'}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// HTML Entities are much easier to troubleshoot in console.
|
||||
he.encode.options.useNamedReferences = true;
|
||||
|
||||
function runTest(test) {
|
||||
var origAttr = test.srcset;
|
||||
var attrDecoded = he.decode(origAttr);
|
||||
var parsed = parseSrcset(attrDecoded);
|
||||
|
||||
var firstCandidate = parsed[0];
|
||||
|
||||
var url = "";
|
||||
var encodedUrl = "";
|
||||
|
||||
if (firstCandidate) {
|
||||
url = firstCandidate.url;
|
||||
}
|
||||
|
||||
// Must re-encode url prior to comparison with expected string.
|
||||
if (url) {
|
||||
encodedUrl = he.encode(url);
|
||||
}
|
||||
|
||||
console.log("");
|
||||
console.log(test.desc);
|
||||
console.log("origAttr: '" + origAttr + "'");
|
||||
console.log("attrDecoded: '" + attrDecoded + "'");
|
||||
console.log("parsed: ", parsed);
|
||||
console.log("url: '" + url + "'");
|
||||
console.log("encodedUrl: '" + encodedUrl + "'");
|
||||
|
||||
|
||||
tdd.test( test.desc , function() {
|
||||
assert.strictEqual(encodedUrl, test.expect, "passed" );
|
||||
});
|
||||
}
|
||||
|
||||
function runTestGroup(testGroup) {
|
||||
var j;
|
||||
var testArray = testGroup.testArray;
|
||||
|
||||
// Group Tests
|
||||
tdd.suite(testGroup.groupName, function() {
|
||||
|
||||
for (j = 0; j < testArray.length; j++) {
|
||||
runTest(testArray[j]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var i;
|
||||
var w3CtestsLength = w3Ctests.length;
|
||||
|
||||
for (i = 0; i < w3CtestsLength; i++) {
|
||||
runTestGroup(w3Ctests[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// tdd.test('First Test', function () {
|
||||
// var parsed = parseSrcset('data:,a 1x');
|
||||
// var url = parsed[0].url;
|
||||
//
|
||||
// console.log("parsed: ", parsed);
|
||||
// console.log("url: ", url);
|
||||
//
|
||||
// assert.strictEqual(parsed, parsed, 'should be');
|
||||
//
|
||||
// // assert.strictEqual(url, 'data:,a', 'should be');
|
||||
// });
|
||||
|
||||
// assert.strictEqual(parseSrcset('data:,a 1x')[0], 'data:,a', 'plain url with descriptor');
|
||||
|
||||
// tdd.test('Second Test', function () {
|
||||
// assert.strictEqual(5, 5, '5 is itself, right?');
|
||||
// });
|
||||
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user