Merge pull request #4284 from nextcloud/techdept/fix-js-tests
Revive js unit tests and add CI check
This commit is contained in:
Коммит
72c4a44b52
|
@ -127,3 +127,18 @@ jobs:
|
|||
file: ./nextcloud/apps/mail/tests/clover.integration.xml
|
||||
flags: integrationtests
|
||||
fail_ci_if_error: true
|
||||
frontend-unit-test:
|
||||
runs-on: ubuntu-latest
|
||||
name: Front-end unit tests
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
- name: npm install
|
||||
run: npm install
|
||||
- name: run tests
|
||||
run: npm run test
|
||||
env:
|
||||
CI: true
|
||||
|
|
|
@ -6,7 +6,8 @@ module.exports = {
|
|||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
useBuiltIns: 'entry',
|
||||
modules: process.env.NODE_ENV === 'testing' ? 'commonjs' : undefined,
|
||||
useBuiltIns: process.env.NODE_ENV === 'testing' ? 'usage' : 'entry',
|
||||
corejs: 3
|
||||
}
|
||||
]
|
||||
|
|
|
@ -5370,11 +5370,6 @@
|
|||
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
|
||||
"integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ="
|
||||
},
|
||||
"deepmerge": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz",
|
||||
"integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg=="
|
||||
},
|
||||
"define-properties": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
|
||||
|
@ -5533,7 +5528,7 @@
|
|||
},
|
||||
"domelementtype": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz",
|
||||
"resolved": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz",
|
||||
"integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w=="
|
||||
},
|
||||
"domexception": {
|
||||
|
@ -7337,61 +7332,14 @@
|
|||
"integrity": "sha512-1qYz89hW3lFDEazhjW0yVAV87lw8lVkrJocr72XmBkMKsoSVJCQx3W8BXsC7hO2qAt8BoVjYjtAcZ9perqGnNg=="
|
||||
},
|
||||
"html-to-text": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-6.0.0.tgz",
|
||||
"integrity": "sha512-r0KNC5aqCAItsjlgtirW6RW25c92Ee3ybQj8z//4Sl4suE3HIPqM4deGpYCUJULLjtVPEP1+Ma+1ZeX1iMsCiA==",
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-5.1.1.tgz",
|
||||
"integrity": "sha512-Bci6bD/JIfZSvG4s0gW/9mMKwBRoe/1RWLxUME/d6WUSZCdY7T60bssf/jFf7EYXRyqU4P5xdClVqiYU0/ypdA==",
|
||||
"requires": {
|
||||
"deepmerge": "^4.2.2",
|
||||
"he": "^1.2.0",
|
||||
"htmlparser2": "^4.1.0",
|
||||
"lodash": "^4.17.20",
|
||||
"minimist": "^1.2.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"dom-serializer": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.1.0.tgz",
|
||||
"integrity": "sha512-ox7bvGXt2n+uLWtCRLybYx60IrOlWL/aCebWJk1T0d4m3y2tzf4U3ij9wBMUb6YJZpz06HCCYuyCDveE2xXmzQ==",
|
||||
"requires": {
|
||||
"domelementtype": "^2.0.1",
|
||||
"domhandler": "^3.0.0",
|
||||
"entities": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"domelementtype": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.0.2.tgz",
|
||||
"integrity": "sha512-wFwTwCVebUrMgGeAwRL/NhZtHAUyT9n9yg4IMDwf10+6iCMxSkVq9MGCVEH+QZWo1nNidy8kNvwmv4zWHDTqvA=="
|
||||
},
|
||||
"domhandler": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-3.3.0.tgz",
|
||||
"integrity": "sha512-J1C5rIANUbuYK+FuFL98650rihynUOEzRLxW+90bKZRWB6A1X1Tf82GxR1qAWLyfNPRvjqfip3Q5tdYlmAa9lA==",
|
||||
"requires": {
|
||||
"domelementtype": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"domutils": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.4.2.tgz",
|
||||
"integrity": "sha512-NKbgaM8ZJOecTZsIzW5gSuplsX2IWW2mIK7xVr8hTQF2v1CJWTmLZ1HOCh5sH+IzVPAGE5IucooOkvwBRAdowA==",
|
||||
"requires": {
|
||||
"dom-serializer": "^1.0.1",
|
||||
"domelementtype": "^2.0.1",
|
||||
"domhandler": "^3.3.0"
|
||||
}
|
||||
},
|
||||
"htmlparser2": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-4.1.0.tgz",
|
||||
"integrity": "sha512-4zDq1a1zhE4gQso/c5LP1OtrhYTncXNSpvJYtWJBtXAETPlMfi3IFNjGuQbYLuVY4ZR0QMqRVvo4Pdy9KLyP8Q==",
|
||||
"requires": {
|
||||
"domelementtype": "^2.0.1",
|
||||
"domhandler": "^3.0.0",
|
||||
"domutils": "^2.0.0",
|
||||
"entities": "^2.0.0"
|
||||
}
|
||||
}
|
||||
"htmlparser2": "^3.10.1",
|
||||
"lodash": "^4.17.11",
|
||||
"minimist": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"htmlparser2": {
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
"watch": "NODE_ENV=development webpack --progress --watch --config webpack.dev.js",
|
||||
"lint": "eslint --ext .js,.vue --ignore-pattern tests src",
|
||||
"lint:fix": "eslint --ext .js,.vue --ignore-pattern tests src --fix",
|
||||
"test": "mochapack --webpack-config webpack.test.js --require src/tests/setup.js \"src/tests/**/*.spec.js\"",
|
||||
"test:watch": "mochapack -w --webpack-config webpack.test.js --require src/tests/setup.js \"src/tests/**/*.spec.js\""
|
||||
"test": "NODE_ENV=testing mochapack --webpack-config webpack.test.js --require src/tests/setup.js \"src/tests/**/*.spec.js\"",
|
||||
"test:watch": "NODE_ENV=testing mochapack -w --webpack-config webpack.test.js --require src/tests/setup.js \"src/tests/**/*.spec.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@bundle-analyzer/webpack-plugin": "^0.5.1",
|
||||
|
@ -48,7 +48,7 @@
|
|||
"davclient.js": "git+https://github.com/owncloud/davclient.js.git#0.2.1",
|
||||
"debounce-promise": "^3.1.2",
|
||||
"dompurify": "^2.2.6",
|
||||
"html-to-text": "^6.0.0",
|
||||
"html-to-text": "^5.1.1",
|
||||
"ical.js": "^1.4.0",
|
||||
"iframe-resizer": "^4.2.11",
|
||||
"js-base64": "^3.6.0",
|
||||
|
|
|
@ -72,7 +72,7 @@ describe('Vuex store actions', () => {
|
|||
const result = await actions.createMailbox(context, {account, name})
|
||||
|
||||
expect(result).to.deep.equal(mailbox)
|
||||
expect(context.commit).to.have.been.calledTwice
|
||||
expect(context.commit).to.have.been.calledThrice
|
||||
expect(context.commit).to.have.been.calledWith('addMailbox', { account, mailbox})
|
||||
})
|
||||
|
||||
|
@ -90,7 +90,7 @@ describe('Vuex store actions', () => {
|
|||
const result = await actions.createMailbox(context, {account, name})
|
||||
|
||||
expect(result).to.deep.equal(mailbox)
|
||||
expect(context.commit).to.have.been.calledTwice
|
||||
expect(context.commit).to.have.been.calledThrice
|
||||
expect(context.commit).to.have.been.calledWith('addMailbox', { account, mailbox})
|
||||
})
|
||||
|
||||
|
@ -108,7 +108,7 @@ describe('Vuex store actions', () => {
|
|||
const result = await actions.createMailbox(context, {account, name})
|
||||
|
||||
expect(result).to.deep.equal(mailbox)
|
||||
expect(context.commit).to.have.been.calledTwice
|
||||
expect(context.commit).to.have.been.calledThrice
|
||||
expect(context.commit).to.have.been.calledWith('addMailbox', { account, mailbox})
|
||||
})
|
||||
|
||||
|
@ -126,7 +126,7 @@ describe('Vuex store actions', () => {
|
|||
const result = await actions.createMailbox(context, {account, name})
|
||||
|
||||
expect(result).to.deep.equal(mailbox)
|
||||
expect(context.commit).to.have.been.calledTwice
|
||||
expect(context.commit).to.have.been.calledThrice
|
||||
expect(context.commit).to.have.been.calledWith('addMailbox', { account, mailbox})
|
||||
})
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import { html, toPlain, plain, detect } from '../../../util/text'
|
||||
import {detect, html, plain, toPlain} from '../../../util/text'
|
||||
|
||||
describe('text', () => {
|
||||
describe('toPlain', () => {
|
||||
|
@ -35,11 +35,10 @@ describe('text', () => {
|
|||
|
||||
it('breaks on divs', () => {
|
||||
const source = html('<div>one</div><div>two</div>')
|
||||
const expected = plain('one\ntwo')
|
||||
|
||||
const actual = toPlain(source)
|
||||
|
||||
expect(actual).to.deep.equal(expected)
|
||||
expect(actual).to.deep.equal(plain('one\ntwo'))
|
||||
})
|
||||
|
||||
it('produces a line break for each ending div element', () => {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
import { curry } from 'ramda'
|
||||
import { htmlToText } from 'html-to-text'
|
||||
import { fromString } from 'html-to-text'
|
||||
|
||||
/**
|
||||
* @type {Text}
|
||||
|
@ -110,29 +110,19 @@ export const toPlain = (text) => {
|
|||
}
|
||||
const withBlockBreaks = text.value.replace(/<\/div>/gi, '</div><br>')
|
||||
|
||||
const converted = htmlToText(withBlockBreaks, {
|
||||
tags: {
|
||||
a: {
|
||||
options: {
|
||||
noLinkBrackets: true,
|
||||
ignoreHref: true,
|
||||
},
|
||||
},
|
||||
img: {
|
||||
format: 'skip',
|
||||
},
|
||||
},
|
||||
const converted = fromString(withBlockBreaks, {
|
||||
noLinkBrackets: true,
|
||||
ignoreHref: true,
|
||||
ignoreImage: true,
|
||||
wordwrap: false,
|
||||
formatters: {
|
||||
blockquote(element, walk, builder, formatOptions) {
|
||||
walk(element.children, builder)
|
||||
format: {
|
||||
blockquote(element, fn, options) {
|
||||
return fn(element.children, options)
|
||||
.replace(/\n\n\n/g, '\n\n') // remove triple line breaks
|
||||
.replace(/^/gm, '> ') // add > quotation to each line
|
||||
},
|
||||
paragraph(element, walk, builder, formatOptions) {
|
||||
walk(element.children, builder)
|
||||
builder.addLineBreak()
|
||||
builder.addLineBreak()
|
||||
paragraph(element, fn, options) {
|
||||
return fn(element.children, options) + '\n\n'
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче