☕️ Classic, reliable, trusted test framework for Node.js and the browser
docs: add example/tests.html to docs-next (#5325)
Josh Goldberg ✨6ec5762edd41
diff --git a/docs-next/public/example/Array.js b/docs-next/public/example/Array.jsnew file mode 100644index 00000000..38cbe39f--- /dev/null+++ b/docs-next/public/example/Array.js@@ -0,0 +1,75 @@+"use strict";++describe('Array', function () {+ describe('.push()', function () {+ it('should append a value', function () {+ var arr = [];+ arr.push('foo');+ arr.push('bar');+ expect(arr[0]).to.equal('foo');+ expect(arr[1]).to.equal('bar');+ })++ it('should return the length', function () {+ var arr = [];+ var n = arr.push('foo');+ expect(n).to.equal(1);+ n = arr.push('bar');+ expect(n).to.equal(2);+ })++ describe('with many arguments', function () {+ it('should add the values', function () {+ var arr = [];+ arr.push('foo', 'bar');+ expect(arr[0]).to.equal('foo');+ expect(arr[1]).to.equal('bar');+ })+ })+ })++ describe('.unshift()', function () {+ it('should prepend a value', function () {+ var arr = [1, 2, 3];+ arr.unshift('foo');+ expect(arr[0]).to.equal('foo');+ expect(arr[1]).to.equal(1);+ })++ it('should return the length', function () {+ var arr = [];+ var n = arr.unshift('foo');+ expect(n).to.equal(1);+ n = arr.unshift('bar');+ expect(n).to.equal(2);+ })++ describe('with many arguments', function () {+ it('should add the values', function () {+ var arr = [];+ arr.unshift('foo', 'bar');+ expect(arr[0]).to.equal('foo');+ expect(arr[1]).to.equal('bar');+ })+ })+ })++ describe('.pop()', function () {+ it('should remove and return the last value', function () {+ var arr = [1, 2, 3];+ expect(arr.pop()).to.equal(3);+ expect(arr.pop()).to.equal(2);+ expect(arr).to.have.length(1);+ })+ })++ describe('.shift()', function () {+ it('should remove and return the first value', function () {+ var arr = [1, 2, 3];+ expect(arr.shift()).to.equal(1);+ expect(arr.shift()).to.equal(2);+ expect(arr).to.have.length(1);+ })+ })+})+diff --git a/docs-next/public/example/tests.html b/docs-next/public/example/tests.htmlnew file mode 100644index 00000000..d52f87c0--- /dev/null+++ b/docs-next/public/example/tests.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<html lang="en">+ <head>+ <meta charset="utf-8">+ <title>Mocha</title>+ <link rel="stylesheet" href="https://unpkg.com/mocha/mocha.css">+ <link rel="shortcut icon" href="../favicon.svg">+ </head>+ <body>+ <div id="mocha"></div>+ <script src="https://unpkg.com/mocha/mocha.js"></script>+ <script src="https://unpkg.com/[email protected]/chai.js"></script>+ <script>mocha.setup('bdd')</script>+ <script>expect = chai.expect</script>+ <script src="Array.js"></script>+ <script>+ mocha.run();+ </script>+ </body>+</html>diff --git a/docs-next/src/content/docs/index.mdx b/docs-next/src/content/docs/index.mdxindex 80f11dd9..29235bae 100644--- a/docs-next/src/content/docs/index.mdx+++ b/docs-next/src/content/docs/index.mdx@@ -52,6 +52,6 @@ Become a [backer](https://opencollective.com/mochajs#support) and support MochaIn addition to chatting with us on [our Discord](https://discord.gg/KeDn2uXhER), for additional information such as usingspies, mocking, and shared behaviours be sure to check out the [Mocha Wiki](https://github.com/mochajs/mocha/wiki) on GitHub.-For a running example of Mocha, view [example/tests.html](https://mochajs.org/example/tests.html).+For a running example of Mocha, view [example/tests.html](example/tests.html).For the JavaScript API, view the [API documentation](/api) or the [source](https://github.com/mochajs/mocha/blob/main/lib/mocha.js).