From 648512107653d931fde3cf208b4795972e60e7ea Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sat, 3 Mar 2018 01:00:29 -0600 Subject: [PATCH 1/5] add jasmine ^3.1.0 --- package-lock.json | 39 +++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 40 insertions(+) diff --git a/package-lock.json b/package-lock.json index 311e5da5ca..2e48745bed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -857,6 +857,20 @@ "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.3.3", + "path-is-absolute": "1.0.1" + } + }, "glob-to-regexp": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz", @@ -1130,6 +1144,22 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, + "jasmine": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.1.0.tgz", + "integrity": "sha1-K9Wf1+xuwOistk4J9Fpo7SrRlSo=", + "dev": true, + "requires": { + "glob": "7.1.2", + "jasmine-core": "3.1.0" + } + }, + "jasmine-core": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.1.0.tgz", + "integrity": "sha1-pHheE11d9lAk38kiSVPfWFvSdmw=", + "dev": true + }, "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", @@ -1271,6 +1301,15 @@ "integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=", "dev": true }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", diff --git a/package.json b/package.json index 11ab79ec2f..bdfd3b0691 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "eslint-plugin-standard": "^3.0.1", "front-matter": "^2.3.0", "glob-to-regexp": "0.3.0", + "jasmine": "^3.1.0", "markdown": "*", "markdown-it": "*", "showdown": "*", From 8a1a31d35fb1ab06924e4441991a6c4d1f095e17 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sat, 3 Mar 2018 01:09:09 -0600 Subject: [PATCH 2/5] add jasmine tests --- .eslintrc.json | 3 ++- jasmine.json | 11 +++++++++++ package.json | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 jasmine.json diff --git a/.eslintrc.json b/.eslintrc.json index 7fae8d3c0e..7fdd614117 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -22,6 +22,7 @@ "env": { "node": true, "browser": true, - "amd": true + "amd": true, + "jasmine": true } } diff --git a/jasmine.json b/jasmine.json new file mode 100644 index 0000000000..8d1be919d1 --- /dev/null +++ b/jasmine.json @@ -0,0 +1,11 @@ +{ + "spec_dir": "test", + "spec_files": [ + "**/*-spec.js" + ], + "helpers": [ + "helpers/**/*.js" + ], + "stopSpecOnExpectationFailure": false, + "random": true +} diff --git a/package.json b/package.json index bdfd3b0691..737f86df16 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,9 @@ "uglify-js": "^3.3.10" }, "scripts": { - "test": "node test", + "test": "npm run test:unit && npm run test:spec", + "test:unit": "jasmine --config=jasmine.json", + "test:spec": "node test", "test:lint": "eslint lib/marked.js test/index.js", "bench": "node test --bench", "lint": "eslint --fix lib/marked.js test/index.js", From dce66a28494df872a713e0326c69a2d818e2ca8f Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sat, 3 Mar 2018 21:33:02 -0600 Subject: [PATCH 3/5] add first test --- test/unit/marked-spec.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/unit/marked-spec.js diff --git a/test/unit/marked-spec.js b/test/unit/marked-spec.js new file mode 100644 index 0000000000..f430302d4c --- /dev/null +++ b/test/unit/marked-spec.js @@ -0,0 +1,5 @@ +var marked = require('../../lib/marked.js'); + +it('should run the test', function () { + expect(marked('Hello World!')).toContain('Hello World!'); +}); From 79325aa9e1dcc2e96a35579ad6e475a8afc7eb05 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sun, 4 Mar 2018 00:47:02 -0600 Subject: [PATCH 4/5] add tests --- package.json | 8 +++++--- test/integration/marked-spec.js | 5 +++++ test/specs/specs-spec.js | 12 ++++++++++++ test/unit/marked-spec.js | 4 +++- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 test/integration/marked-spec.js create mode 100644 test/specs/specs-spec.js diff --git a/package.json b/package.json index 737f86df16..b8a4702ee0 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,11 @@ "uglify-js": "^3.3.10" }, "scripts": { - "test": "npm run test:unit && npm run test:spec", - "test:unit": "jasmine --config=jasmine.json", - "test:spec": "node test", + "test": "jasmine --config=jasmine.json", + "test:unit": "npm test -- test/unit/**/*-spec.js", + "test:specs": "npm test -- test/specs/**/*-spec.js", + "test:integration": "npm test -- test/integration/**/*-spec.js", + "test:old": "node test", "test:lint": "eslint lib/marked.js test/index.js", "bench": "node test --bench", "lint": "eslint --fix lib/marked.js test/index.js", diff --git a/test/integration/marked-spec.js b/test/integration/marked-spec.js new file mode 100644 index 0000000000..6d3b9ee78c --- /dev/null +++ b/test/integration/marked-spec.js @@ -0,0 +1,5 @@ +var marked = require('../../marked.min.js'); + +it('should run the test', function () { + expect(marked('Hello World!')).toBe('

Hello World!

\n'); +}); diff --git a/test/specs/specs-spec.js b/test/specs/specs-spec.js new file mode 100644 index 0000000000..c30a8429dd --- /dev/null +++ b/test/specs/specs-spec.js @@ -0,0 +1,12 @@ +var tests = require('../'); + +it('should run spec tests', function () { + // hide output + spyOn(console, 'log'); + if (!tests.runTests({stop: true})) { + // if tests fail rerun tests and show output + console.log.and.callThrough(); + tests.runTests(); + fail(); + } +}); diff --git a/test/unit/marked-spec.js b/test/unit/marked-spec.js index f430302d4c..83f4fb57a0 100644 --- a/test/unit/marked-spec.js +++ b/test/unit/marked-spec.js @@ -1,5 +1,7 @@ var marked = require('../../lib/marked.js'); it('should run the test', function () { - expect(marked('Hello World!')).toContain('Hello World!'); + spyOn(marked, 'parse').and.callThrough(); + marked.parse('Hello World!'); + expect(marked.parse).toHaveBeenCalled(); }); From 9c6c13f3d3d095bdcb2d9a3b72095e21398ec8d7 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sun, 4 Mar 2018 00:51:00 -0600 Subject: [PATCH 5/5] fix tests --- test/specs/specs-spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/specs/specs-spec.js b/test/specs/specs-spec.js index c30a8429dd..65526c863c 100644 --- a/test/specs/specs-spec.js +++ b/test/specs/specs-spec.js @@ -1,12 +1,12 @@ -var tests = require('../'); +var specTests = require('../'); it('should run spec tests', function () { // hide output spyOn(console, 'log'); - if (!tests.runTests({stop: true})) { + if (!specTests({stop: true})) { // if tests fail rerun tests and show output console.log.and.callThrough(); - tests.runTests(); + specTests(); fail(); } });