diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..034c3cd --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,13 @@ +pipeline { + agent any + + stages { + stage('mocha') { + steps { + sh 'npm install --dev' + sh 'npm run test' + } + } + } +} + diff --git a/package.json b/package.json index fdd1af2..4edfcec 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,9 @@ "description": "Web scraper using CSS selector", "version": "1.1.0", "main": "src/index.js", - "devDependencies": {}, + "devDependencies": { + "mocha": "^8.1.3" + }, "dependencies": { "cheerio": "^1.0.0-rc.3", "extends-classes": "^1.0.5", @@ -14,7 +16,7 @@ "trim": "^0.0.1" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "mocha" }, "repository": { "type": "git", diff --git a/test/breaks.test.js b/test/breaks.test.js new file mode 100644 index 0000000..53672d7 --- /dev/null +++ b/test/breaks.test.js @@ -0,0 +1,20 @@ +const filter = require('../src/filter/breaks') +const assert = require('assert') + +describe('Check "breaks"', () => { + it('Should return empty string', () => { + assert.equal(filter("\n"), "") + }) + + it('Should return empty string', () => { + assert.equal(filter("\r"), "") + }) + + it('Should return "foo"', () => { + assert.equal(filter("foo"), "foo") + }) + + it('Should return "foobar"', () => { + assert.equal(filter("\r\nfoo\nbar\r\n"), "foobar") + }) +}); diff --git a/test/spaces.test.js b/test/spaces.test.js new file mode 100644 index 0000000..6551871 --- /dev/null +++ b/test/spaces.test.js @@ -0,0 +1,16 @@ +const filter = require('../src/filter/spaces') +const assert = require('assert') + +describe('Check "spaces"', () => { + it('Should return ""', () => { + assert.equal(filter(""), "") + }) + + it('Should return "foo bar"', () => { + assert.equal(filter("foo bar"), "foo bar") + }) + + it('Should return "foo bar"', () => { + assert.equal(filter("foo \nbar"), "foo bar") + }) +}); diff --git a/test/tags.test.js b/test/tags.test.js new file mode 100644 index 0000000..de29bfb --- /dev/null +++ b/test/tags.test.js @@ -0,0 +1,5 @@ +const filter = require('../src/filter/tags') +const assert = require('assert') + +describe('Check "tags"', () => { +}); diff --git a/test/trim.test.js b/test/trim.test.js new file mode 100644 index 0000000..36c8f0e --- /dev/null +++ b/test/trim.test.js @@ -0,0 +1,20 @@ +const filter = require('../src/filter/trim') +const assert = require('assert') + +describe('Check "trim"', () => { + it('Should return ""', () => { + assert.equal(filter(""), "") + }) + + it('Should return ""', () => { + assert.equal(filter(" "), "") + }) + + it('Should return "foo"', () => { + assert.equal(filter(" foo "), "foo") + }) + + it('Should return "foo bar"', () => { + assert.equal(filter(" foo bar \n"), "foo bar") + }) +});