• Sean Hammond's avatar
    Read query from the host page in settings.query() · 30160267
    Sean Hammond authored
    Add code to the `settings.query()` method so that, instead of reading
    the setting from the URL only, it reads the query setting from the
    `js-hypothesis-config` scripts in the host page or, failing that, tries
    to read it from the URL.
    
    In `index.js`, after `settings.query()` is called, there are two
    `Object.assign()` calls that overwrite values already in the `config`
    objects with any returned from `js-hypothesis-config` scripts or the
    `window.hypothesisConfig()` function in the host page. So a
    `config.query` setting from `settings.query()` already gets overwritten
    by a `query` setting in a `js-hypothesis-config` script or
    `hypothesisConfig()` function.
    
    This commit makes that overwriting explicit, encapsulates it in the
    `query()` method, and unit tests it.
    
    Note that the two `Object.assign()`s are still present in `index.js` so
    the `config.query` setting returned by the `query()` method still gets
    overwritten by them, but this now has no effect as the `query()` method
    will already have set `config.query` to the same value that it will be
    overwritten with.
    
    In a future commit the `Object.assign()`s will be removed and there
    won't be any overwriting.
    
    Note that **this will change the behaviour of the code** once the
    `Object.assign()`s have been removed: the `query()` method reads the
    query setting from `js-hypothesis-config` scripts but does not read it
    from `window.hypothesisConfig()` any longer. I don't believe it's
    necessary to read `query` from `hypothesisConfig()`.
    30160267
Name
Last commit
Last update
.github Loading commit data...
docs Loading commit data...
images Loading commit data...
scripts Loading commit data...
src Loading commit data...
.babelrc Loading commit data...
.eslintignore Loading commit data...
.eslintrc Loading commit data...
.gitignore Loading commit data...
.npmignore Loading commit data...
.npmrc Loading commit data...
.travis.yml Loading commit data...
CHANGELOG.md Loading commit data...
CODE_OF_CONDUCT Loading commit data...
Jenkinsfile Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
gulpfile.js Loading commit data...
package.json Loading commit data...
requirements-dev.in Loading commit data...
yarn.lock Loading commit data...