diff --git a/library.js b/library.js index 33f8014..c12131b 100644 --- a/library.js +++ b/library.js @@ -4,7 +4,8 @@ var controllers = require('./lib/controllers'); var YoutubeLite = {}, embed = '
'; - var regularUrl = /|^) https://youtu.be/fXhUgV9qzI0 Look at thishttps://youtu.be/fXhUgV9qzI0 Look at thishttps://youtu.be/fXhUgV9qzI0 https://youtu.be/fXhUgV9qzI0 uh huh https://youtu.be/fXhUgV9qzI0 uh huh Look: https://youtu.be/fXhUgV9qzI0 uh huh Look: https://youtu.be/fXhUgV9qzI0 uh huh
|<\/p>)/mg;
+YoutubeLite.regularUrl = regularUrl;
YoutubeLite.init = function(params, callback) {
var router = params.router,
diff --git a/package.json b/package.json
index 2e2e027..b57a368 100644
--- a/package.json
+++ b/package.json
@@ -7,12 +7,17 @@
"description": "NodeBB Youtube Lite Plugin",
"main": "library.js",
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
+ "test": "mocha ./tests"
},
"repository": {
"type": "git",
"url": "git+https://github.com/a5mith/nodebb-plugin-youtube-lite.git"
},
+ "devDependencies": {
+ "chai": "^3.5.0",
+ "mocha": "^2.4.5",
+ "winston": "^2.2.0"
+ },
"keywords": [
"nodebb",
"plugin",
diff --git a/tests/regex.js b/tests/regex.js
new file mode 100644
index 0000000..571395e
--- /dev/null
+++ b/tests/regex.js
@@ -0,0 +1,66 @@
+'use strict';
+var winston = require('winston');
+
+process.on('uncaughtException', function (err) {
+ winston.error('Encountered error while running test suite: ' + err.message);
+});
+
+var expect = require("chai").expect;
+
+var youtubeLite = require("../library");
+
+var posts = [
+ {
+ description: 'Simple post with only the youtube link',
+ content: '',
+ expected: ''
+ },
+ {
+ description: 'Markdown link with a youtube URL should be left alone',
+ content: '',
+ expected: ''
+ },
+ {
+ description: 'Video URLs on consecutive lines',
+ content: '
\nhttps://youtu.be/fXhUgV9qzI0