Update CONTRIBUTING and fix tests
This commit is contained in:
parent
1eb2e148bd
commit
b53d269bfe
18 changed files with 65 additions and 412 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable import/no-commonjs */
|
||||
module.exports = {
|
||||
extends: ['algolia/jest'],
|
||||
extends: ['algolia', 'algolia/jest'],
|
||||
globals: {
|
||||
instantsearch: true,
|
||||
search: true,
|
||||
|
|
|
|||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -5,9 +5,6 @@ dist/
|
|||
.idea/
|
||||
npm-debug.log*
|
||||
yarn-error.log
|
||||
docs/_site
|
||||
docs/build
|
||||
docs/.sass-cache/
|
||||
dist-es5-module/
|
||||
yarn.lock
|
||||
tmp
|
||||
|
|
|
|||
103
CONTRIBUTING.md
103
CONTRIBUTING.md
|
|
@ -34,97 +34,34 @@ To run this project, you will need:
|
|||
- [Ruby](https://www.ruby-lang.org/en/)
|
||||
- [Bundler](http://bundler.io/)
|
||||
|
||||
## Launch
|
||||
## Build
|
||||
|
||||
```sh
|
||||
npm install
|
||||
npm run dev:docs
|
||||
```
|
||||
`yarn run build` will build all files in `./dist`. This includes regular and
|
||||
minified files for `<script>` inclusion, as well as classes for `import`ing.
|
||||
|
||||
Then go to:
|
||||
- http://localhost:4000/docsearch/ documentation website with autoreload
|
||||
- http://localhost:8080 local DocSearch example for easy hacking/additions/fixes
|
||||
The command itself is split into `yarn run build:js` and `yarn run build:css` if
|
||||
you want to build only a subset.
|
||||
|
||||
## Local build
|
||||
## Serve
|
||||
|
||||
You might want to expose a local build to the outside to test things on real
|
||||
websites. To do so:
|
||||
You can have all this files served on localhost, along with live-reload, with
|
||||
the `yarn run serve` command.
|
||||
|
||||
```sh
|
||||
npm run serve
|
||||
```
|
||||
## Test
|
||||
|
||||
Then files will be available at http://localhost:8080. Use [ngrok](https://ngrok.com/download) to
|
||||
then expose your build to the web.
|
||||
You can run all tests with `yarn run test`, and `yarn run test:watch` will run
|
||||
them with auto-reload.
|
||||
|
||||
# Commit message guidelines
|
||||
## Docs
|
||||
|
||||
We use [conventional changelog](https://github.com/ajoslin/conventional-changelog) to generate our changelog from our git commit messages.
|
||||
- `yarn docs:build` will build the docs website in `./docs/dist`.
|
||||
- `yarn docs:serve` will do the same, but with live-reload enabled
|
||||
- `yarn docs:lint` will check for linting errors in the doc website
|
||||
- `yarn docs:deploy` will deploy the doc website
|
||||
|
||||
Here are the rules to write commit messages, they are the same than [angular/angular.js](https://github.com/angular/angular.js/blob/7c792f4cc99515ac27ed317e0e35e40940b3a400/CONTRIBUTING.md#commit-message-format).
|
||||
## Release
|
||||
|
||||
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
|
||||
format that includes a **type**, a **scope** and a **subject**:
|
||||
`npm run release` will guid you through the release process. Note that you have
|
||||
to use `npm` and not `yarn` for this one otherwise it won't correctly deploy to
|
||||
npm.
|
||||
|
||||
```text
|
||||
<type>(<scope>): <subject>
|
||||
<BLANK LINE>
|
||||
<body>
|
||||
<BLANK LINE>
|
||||
<footer>
|
||||
```
|
||||
|
||||
The **header** is mandatory and the **scope** of the header is optional.
|
||||
|
||||
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier
|
||||
to read on GitHub as well as in various git tools.
|
||||
|
||||
## Revert
|
||||
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
|
||||
|
||||
## Type
|
||||
Must be one of the following:
|
||||
|
||||
* **feat**: A new feature
|
||||
* **fix**: A bug fix
|
||||
* **docs**: Documentation only changes
|
||||
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing
|
||||
semi-colons, etc)
|
||||
* **refactor**: A code change that neither fixes a bug nor adds a feature
|
||||
* **perf**: A code change that improves performance
|
||||
* **test**: Adding missing tests
|
||||
* **chore**: Changes to the build process or auxiliary tools and libraries such as documentation
|
||||
generation
|
||||
|
||||
## Scope
|
||||
The scope could be anything specifying place of the commit change. For example `RefinementList`,
|
||||
`refinementList`, `rangeSlider`, `CI`, `url`, `build` etc...
|
||||
|
||||
## Subject
|
||||
The subject contains succinct description of the change:
|
||||
|
||||
* use the imperative, present tense: "change" not "changed" nor "changes"
|
||||
* don't capitalize first letter
|
||||
* no dot (.) at the end
|
||||
|
||||
## Body
|
||||
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
|
||||
The body should include the motivation for the change and contrast this with previous behavior.
|
||||
|
||||
## Footer
|
||||
The footer should contain any information about **Breaking Changes** and is also the place to
|
||||
reference GitHub issues that this commit **Closes**.
|
||||
|
||||
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
|
||||
|
||||
# Releasing
|
||||
|
||||
If you are a maintainer, you can release.
|
||||
|
||||
We use [semver](http://semver-ftw.org/).
|
||||
|
||||
You must be on the master branch.
|
||||
|
||||
```sh
|
||||
npm run release
|
||||
```
|
||||
11
dev/app.js
11
dev/app.js
|
|
@ -1,11 +0,0 @@
|
|||
// eslint-disable-next-line import/no-commonjs
|
||||
const docsearch = require('../index.js');
|
||||
|
||||
docsearch({
|
||||
apiKey: 'e3d767b736584dbe6d4c35f7cf7d4633',
|
||||
indexName: 'react-native',
|
||||
inputSelector: '#search-input',
|
||||
debug: true,
|
||||
});
|
||||
|
||||
document.getElementById('search-input').focus();
|
||||
|
|
@ -1 +0,0 @@
|
|||
../dist/cdn/docsearch.css
|
||||
1
dev/docsearch.min.css
vendored
1
dev/docsearch.min.css
vendored
|
|
@ -1 +0,0 @@
|
|||
../dist/cdn/docsearch.min.css
|
||||
227
dev/index.html
227
dev/index.html
|
|
@ -1,227 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="/stripe.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="/docsearch.css" media="screen" />
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
|
||||
<body id="documentation">
|
||||
|
||||
<div id="header">
|
||||
<h1><a href="index.html">Stripe</a></h1>
|
||||
<div class="navigation">
|
||||
<div class="signin"><a id='signin' href="https://dashboard.stripe.com/login"><span>Sign In</span></a></div>
|
||||
|
||||
<ul class="global">
|
||||
<li><input type="text" id="search-input" /></li>
|
||||
<li><a href="country%3Fcountry=CH&redirect=%252Fdocs.html" class="selected">Documentation</a></li>
|
||||
<li><a href="https://support.stripe.com">Help & Support</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- #header -->
|
||||
|
||||
<section id="doc">
|
||||
|
||||
|
||||
<nav>
|
||||
|
||||
<h1 class="references">Development</h1>
|
||||
<ul>
|
||||
<li class="selected"><a href="country%3Fcountry=CH&redirect=%252Fdocs.html">Getting Started</a></li>
|
||||
<li class="unselected sub"><a href="docs/tutorials/checkout.html">Embedded Form</a></li>
|
||||
<li class="unselected sub"><a href="docs/tutorials/forms.html">Custom Forms</a></li>
|
||||
<li class="unselected sub"><a href="docs/mobile.html">Mobile Apps</a></li>
|
||||
<li class="unselected"><a href="docs/tutorials/charges.html">Charging Cards</a></li>
|
||||
<li class="unselected"><a href="docs/testing.html">Testing</a></li>
|
||||
<li class="unselected"><a href="help/security.html">Security</a></li>
|
||||
<li class="unselected"><a href="docs/fraud.html">Fraud Protection</a></li>
|
||||
<li class="unselected"><a href="docs/webhooks.html">Webhooks</a></li>
|
||||
<li class="unselected"><a href="docs/guides/bitcoin.html">Bitcoin Guide</a></li>
|
||||
<li class="unselected"><a href="docs/guides/alipay.html">Alipay Guide</a></li>
|
||||
<li class="unselected"><a href="docs/guides/file-upload.html">File Upload Guide</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 class="getting-started">Account</h1>
|
||||
<ul>
|
||||
<li class="unselected"><a href="docs/tutorials/dashboard.html">Your Account</a></li>
|
||||
<li class="unselected"><a href="help/transfers.html">Getting Paid</a></li>
|
||||
<li class="unselected"><a href="help/disputes-overview.html">Disputes</a></li>
|
||||
<li class="unselected sub"><a href="docs/guides/dispute-evidence.html">Submitting Evidence</a></li>
|
||||
<li class="unselected sub"><a href="help/dispute-types.html">Dispute Types</a></li>
|
||||
<li class="unselected sub"><a href="help/disputes.html">Disputes FAQ</a></li>
|
||||
<li class="unselected"><a href="docs/integrations.html">Integrations</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 class="faq">References</h1>
|
||||
<ul>
|
||||
<li class="unselected"><a href="docs/examples.html">Examples</a></li>
|
||||
<li class="unselected"><a href="docs/stripe.js.html">Stripe.js</a></li>
|
||||
<li class="unselected"><a href="docs/checkout.html">Checkout</a></li>
|
||||
<li class="unselected"><a href="docs/libraries.html">API Libraries</a></li>
|
||||
<li class="unselected"><a href="docs/upgrades.html">API Upgrades</a></li>
|
||||
|
||||
<li class="unselected">
|
||||
<a href="docs/api.html" class="external" target="_blank">Full API Reference</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h1 class="subscriptions">Subscriptions</h1>
|
||||
<ul>
|
||||
<li class="unselected"><a href="docs/subscriptions.html">Overview</a></li>
|
||||
<li class="unselected"><a href="docs/tutorials/subscriptions.html">Getting Started</a></li>
|
||||
<li class="unselected"><a href="docs/guides/subscriptions.html">Integration Guide</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 class="orders">Relay</h1>
|
||||
<ul>
|
||||
<li class="unselected"><a href="docs/relay.html">Overview</a></li>
|
||||
<li class="unselected"><a href="docs/relay/apps-guide.html">Apps Guide</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 class="connect">Connect</h1>
|
||||
<ul>
|
||||
<li class="unselected"><a href="docs/connect.html">Overview</a></li>
|
||||
<li class="unselected"><a href="docs/connect/connecting-to-accounts.html">Connecting to Accounts</a></li>
|
||||
<li class="unselected sub"><a href="docs/connect/standalone-accounts.html">Standalone Accounts</a></li>
|
||||
<li class="unselected sub"><a href="docs/connect/authentication.html">Authentication</a></li>
|
||||
<li class="unselected sub"><a href="docs/connect/reference.html">OAuth Reference</a></li>
|
||||
<li class="unselected"><a href="docs/connect/payments-fees.html">Payments and Fees</a></li>
|
||||
<li class="unselected"><a href="docs/connect/special-case-transfers.html">Special-case Transfers</a></li>
|
||||
<li class="unselected"><a href="docs/connect/managed-accounts.html">Managed Accounts</a></li>
|
||||
<li class="unselected sub"><a href="docs/connect/updating-accounts.html">Updating Accounts</a></li>
|
||||
<li class="unselected sub"><a href="docs/connect/identity-verification.html">Identity Verification</a></li>
|
||||
<li class="unselected sub"><a href="docs/connect/bank-transfers.html">Bank Transfers</a></li>
|
||||
<li class="unselected sub"><a href="docs/connect/migrating.html">Migrating Recipients</a></li>
|
||||
<li class="unselected"><a href="docs/connect/testing.html">Testing</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 class="more">About Stripe</h1>
|
||||
<ul>
|
||||
<li class="unselected"><a href="help/contact.html">Contact</a></li>
|
||||
<li class="unselected"><a href="global.html">Global Users</a></li>
|
||||
<li class="unselected last"><a href="gallery.html">Gallery</a></li>
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
|
||||
<section id="content">
|
||||
<section id="start">
|
||||
|
||||
<header>
|
||||
<h1>Getting Started</h1>
|
||||
<p>
|
||||
Below you'll find tutorials that will teach you how to use Stripe, and reference documentation for all the moving parts.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<section class="getting-started">
|
||||
|
||||
<div class="implementation-options">
|
||||
|
||||
<div class="guides">
|
||||
<a class="web" href="docs/tutorials/checkout.html">
|
||||
<h2>On your website</h2>
|
||||
<p>
|
||||
Start accepting payments on your website with our JavaScript libraries. <span class="arrow">Learn more</span>
|
||||
</p>
|
||||
</a>
|
||||
<a class="mobile" href="docs/mobile.html">
|
||||
<h2>In your mobile app</h2>
|
||||
<p>
|
||||
We have toolkits for native iPhone and Android applications. <span class="arrow">Learn more</span>
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="payment-types">
|
||||
<h3>Accept different payment types</h3>
|
||||
<p>
|
||||
In addition to charging <a href="docs/tutorials/charges.html">credit and debit cards</a>, Stripe's APIs let you accept payments on <a href="docs/mobile/android.html">Android</a> and <a href="docs/mobile/ios.html">iOS</a>. You can also support <a href="docs/guides/bitcoin.html">Bitcoin</a>, <a href="docs/guides/alipay.html">Alipay</a>, or <a href="docs/guides/amex-express-checkout.html">Amex Express Checkout</a>.
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
<div class="non-developer">
|
||||
<a class="platforms" href="docs/libraries.html#third-party-plugins">
|
||||
<h3>Stripe plugins for 3rd party software</h3>
|
||||
<p>
|
||||
As well as the official API libraries listed above, there are a number of third-party plugins and libraries built by our community, such as for WordPress and Drupal.
|
||||
|
||||
<span class="arrow">Learn more</span>
|
||||
</p>
|
||||
</a>
|
||||
|
||||
<a class="services" href="docs/integrations.html">
|
||||
<h3>Use Stripe with other services</h3>
|
||||
<p>
|
||||
Stripe has lots of third-party integrations which require no programming, hosting or complicated setup on your behalf, such as Shopify and Wufoo.
|
||||
|
||||
<span class="arrow">Learn more</span>
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<section id="details">
|
||||
<article>
|
||||
<hr>
|
||||
<h2>Need help?</h2>
|
||||
<p>We're always happy to help out with code or any other questions you might have. <a href="https://support.stripe.com" class="arrow">Learn more</a></p>
|
||||
|
||||
<h2>API mailing list</h2>
|
||||
<p>Join our mailing list to be notified of API changes and stay up to date. <a href="https://groups.google.com/a/lists.stripe.com/forum/#!forum/api-discuss" class="arrow">View mailing list</a></p>
|
||||
|
||||
<h2>Resources</h2>
|
||||
<ul>
|
||||
<li><a href="docs/libraries.html">API libraries</a></li>
|
||||
<li><a href="docs/examples.html">Example projects</a></li>
|
||||
</ul>
|
||||
</article>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
<footer class="clearfix">
|
||||
<section class="questions">
|
||||
<h1>Questions?</h1>
|
||||
<p>We're always happy to help with code or other questions you might have! Check out our answers to <a href="https://support.stripe.com">common questions</a> or chat live with other developers in <a href="irc://irc.freenode.net/stripe">#stripe</a> on freenode.</p>
|
||||
|
||||
</section>
|
||||
</footer>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
<!-- #documentation -->
|
||||
|
||||
<div id="footer">
|
||||
|
||||
<p><a href="index.html">© Stripe</a></p>
|
||||
|
||||
<ul>
|
||||
<li><a href="https://status.stripe.com"><span>System Status</span></a></li>
|
||||
<li><a href="about.html">About</a></li>
|
||||
<li><a href="blog.html"><span>Blog</span></a></li>
|
||||
<li><a href="jobs.html"><span>Jobs</span></a></li>
|
||||
<li><a href="http://twitter.com/stripe">Twitter</a></li>
|
||||
</ul>
|
||||
<ul class="lesser">
|
||||
<li><a href="terms.html">Terms of Service</a></li>
|
||||
<li><a href="privacy.html">Privacy Policy</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="country-dropdown-overlay"></div>
|
||||
|
||||
<script src="/bundle.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
7
jest.config.js
Normal file
7
jest.config.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* eslint-disable import/no-commonjs */
|
||||
module.exports = {
|
||||
bail: true,
|
||||
resetMocks: true,
|
||||
restoreMocks: true,
|
||||
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/docs/'],
|
||||
};
|
||||
27
package.json
27
package.json
|
|
@ -4,21 +4,19 @@
|
|||
"description": "Add an autocomplete dropdown to your documentation",
|
||||
"main": "dist/npm/index.js",
|
||||
"scripts": {
|
||||
"dev": "./scripts/dev",
|
||||
"serve": "./scripts/serve",
|
||||
"doctoc": "doctoc --maxlevel 3 README.md CONTRIBUTING.md",
|
||||
"build": "./scripts/build",
|
||||
"build:css": "./scripts/build-css",
|
||||
"build:js": "./scripts/build-js",
|
||||
"docs:build": "cd ./docs && yarn build",
|
||||
"docs:lint": "cd ./docs && yarn lint",
|
||||
"docs:serve": "cd ./docs && yarn serve",
|
||||
"doctoc": "doctoc --maxlevel 3 README.md CONTRIBUTING.md",
|
||||
"lint": "./scripts/lint",
|
||||
"release": "./scripts/release",
|
||||
"release:beta": "./scripts/release-beta",
|
||||
"lint": "./scripts/lint",
|
||||
"lint:fix": "npm run lint -- --fix",
|
||||
"serve": "./scripts/serve",
|
||||
"test": "./scripts/test",
|
||||
"test:watch": "jest --watch",
|
||||
"docs:build": "cd ./docs && yarn build",
|
||||
"docs:serve": "cd ./docs && yarn serve",
|
||||
"docs:lint": "cd ./docs && yarn lint"
|
||||
"test:watch": "./scripts/test-watch"
|
||||
},
|
||||
"files": [
|
||||
"dist/"
|
||||
|
|
@ -57,10 +55,10 @@
|
|||
"eslint-plugin-import": "2.14.0",
|
||||
"eslint-plugin-jest": "21.21.0",
|
||||
"eslint-plugin-prettier": "2.6.2",
|
||||
"gh-pages": "1.2.0",
|
||||
"jest": "21.2.1",
|
||||
"jest": "23.0.0",
|
||||
"jsdom": "11.12.0",
|
||||
"json": "9.0.6",
|
||||
"live-server": "^1.2.0",
|
||||
"mversion": "1.12.0",
|
||||
"node-sass": "4.9.3",
|
||||
"onchange": "4.1.0",
|
||||
|
|
@ -71,20 +69,17 @@
|
|||
"sinon": "6.1.5",
|
||||
"uglify-js": "3.4.7",
|
||||
"webpack": "3.12.0",
|
||||
"webpack-dev-server": "3.1.5"
|
||||
"webpack-cli": "^3.1.0"
|
||||
},
|
||||
"peerDependencies": {},
|
||||
"dependencies": {
|
||||
"algoliasearch": "^3.24.5",
|
||||
"autocomplete.js": "^0.31.0",
|
||||
"hogan.js": "^3.0.2",
|
||||
"parallelshell": "^3.0.2",
|
||||
"request": "^2.87.0",
|
||||
"stack-utils": "^1.0.1",
|
||||
"to-factory": "^1.0.0",
|
||||
"zepto": "^1.2.0"
|
||||
},
|
||||
"jest": {
|
||||
"verbose": true,
|
||||
"testURL": "http://localhost/"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e # exit when error
|
||||
set -e
|
||||
|
||||
rm -rf dist
|
||||
|
||||
# JavaScript
|
||||
npm run build:js
|
||||
npm run build:css
|
||||
|
||||
# Documentation
|
||||
npm run build:docs
|
||||
yarn run build:js
|
||||
yarn run build:css
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
npm run build:css
|
||||
|
||||
webpack-dev-server --config webpack.dev.config.babel.js &
|
||||
onchange './src/styles/*.scss' -- npm run build:css &
|
||||
wait
|
||||
|
|
@ -1,24 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
# Serves the current build version on a local server available (by default) on
|
||||
# http://127.0.0.1:8080/docsearch.js and http://127.0.0.1/docsearch.css
|
||||
#
|
||||
# This is useful when you want to test the latest docsearch.js version
|
||||
# (including your own branches) on a specific local project. Just run `npm run
|
||||
# serve` in the docsearch repository, and link the file in your project.
|
||||
#
|
||||
# This works by running webpack in watch mode as well as simply serving the dist
|
||||
# folder through a local web server.
|
||||
|
||||
npm run build:css
|
||||
yarn run build:css
|
||||
|
||||
# Watch changes and rebuild file if needed
|
||||
NODE_ENV=production \
|
||||
webpack \
|
||||
--config webpack.serve.config.babel.js \
|
||||
-w &
|
||||
# Serve files
|
||||
cd dist/cdn && http-server &
|
||||
# Rebuild css
|
||||
onchange './src/styles/*.scss' -- npm run build:css & \
|
||||
|
||||
wait
|
||||
echo "Find all files at http://127.0.0.1:8080/";
|
||||
parallelshell \
|
||||
'webpack --config webpack.serve.config.babel.js -w' \
|
||||
'onchange "./src/styles/*.scss" -- yarn run build:css' \
|
||||
'live-server ./dist/cdn' \
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env sh
|
||||
set -e
|
||||
|
||||
jest --no-cache ./src/lib/__tests__/utils-test.js
|
||||
jest \
|
||||
--no-cache \
|
||||
./src/lib/
|
||||
|
|
|
|||
7
scripts/test-watch
Executable file
7
scripts/test-watch
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
set -e
|
||||
jest \
|
||||
--no-cache \
|
||||
--watch \
|
||||
./src/lib/
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ class DocSearch {
|
|||
|
||||
handleSelected(input, event, suggestion) {
|
||||
input.setVal('');
|
||||
window.location.href = suggestion.url;
|
||||
window.location.assign(suggestion.url);
|
||||
}
|
||||
|
||||
handleShown(input) {
|
||||
|
|
|
|||
|
|
@ -3,10 +3,6 @@
|
|||
import sinon from 'sinon';
|
||||
import $ from '../zepto.js';
|
||||
import DocSearch from '../DocSearch.js';
|
||||
Object.defineProperty(window.location, 'href', {
|
||||
writable: true,
|
||||
value: 'some url',
|
||||
});
|
||||
|
||||
describe('DocSearch', () => {
|
||||
beforeEach(() => {
|
||||
|
|
@ -22,6 +18,8 @@ describe('DocSearch', () => {
|
|||
|
||||
// We prevent the logging of expected errors
|
||||
window.console.warn = sinon.spy();
|
||||
|
||||
window.location.assign = jest.fn();
|
||||
});
|
||||
|
||||
describe('constructor', () => {
|
||||
|
|
@ -405,8 +403,11 @@ describe('DocSearch', () => {
|
|||
ds.autocomplete.trigger('autocomplete:selected', {
|
||||
url: 'https://website.com/doc/page',
|
||||
});
|
||||
|
||||
return new Promise(resolve => {
|
||||
expect(window.location.href).toEqual('https://website.com/doc/page');
|
||||
expect(window.location.assign).toHaveBeenCalledWith(
|
||||
'https://website.com/doc/page'
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
import { join } from 'path';
|
||||
|
||||
export default {
|
||||
entry: './dev/app.js',
|
||||
devtool: 'source-map',
|
||||
output: {
|
||||
path: join(__dirname, 'dev/'),
|
||||
filename: 'bundle.js',
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'babel-loader',
|
||||
},
|
||||
],
|
||||
},
|
||||
devServer: {
|
||||
contentBase: 'dev/',
|
||||
host: '0.0.0.0',
|
||||
compress: true,
|
||||
},
|
||||
};
|
||||
Loading…
Reference in a new issue