mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
Add jasmine for message-processor
This commit is contained in:
parent
b67a3ae3e4
commit
0ac3c8c313
4 changed files with 33 additions and 21 deletions
|
@ -5,8 +5,19 @@
|
|||
"main": "index.js",
|
||||
"author": "Nylas",
|
||||
"license": "ISC",
|
||||
"scripts": {
|
||||
"test": "babel-node spec/run.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"mailparser": "0.6.0",
|
||||
"nylas-core": "0.x.x"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.10.1",
|
||||
"babel-preset-es2015": "^6.9.0",
|
||||
"jasmine": "^2.4.1"
|
||||
},
|
||||
"babel": {
|
||||
"presets": ["es2015"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +1,24 @@
|
|||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const assert = require('assert')
|
||||
const {processMessage} = require('../processors/parsing')
|
||||
|
||||
const BASE_PATH = path.join('/', 'Users', 'juan', 'Downloads', 'sample data')
|
||||
|
||||
const tests = []
|
||||
|
||||
function it(name, testFn) {
|
||||
tests.push(testFn)
|
||||
}
|
||||
|
||||
function test() {
|
||||
tests.reduce((prev, t) => prev.then(() => t()), Promise.resolve())
|
||||
.then(() => console.log('Success!'))
|
||||
.catch((err) => console.log(err))
|
||||
}
|
||||
|
||||
it('parses the message correctly', () => {
|
||||
it('parses the message correctly', (done) => {
|
||||
const bodyPath = path.join(BASE_PATH, '1-99174-body.txt')
|
||||
const headersPath = path.join(BASE_PATH, '1-99174-headers.txt')
|
||||
const rawBody = fs.readFileSync(bodyPath, 'utf8')
|
||||
const rawHeaders = fs.readFileSync(headersPath, 'utf8')
|
||||
const message = { rawHeaders, rawBody }
|
||||
return processMessage({message}).then((processed) => {
|
||||
const bodyPart = `<p>In <a href="https://github.com/electron/electron.atom.io/pull/352#discussion_r67715160">_data/apps.yml</a>:</p>`
|
||||
assert.equal(processed.headers['in-reply-to'], '<electron/electron.atom.io/pull/352@github.com>')
|
||||
assert.equal(processed.messageId, '<electron/electron.atom.io/pull/352/r67715160@github.com>')
|
||||
assert.equal(processed.subject, 'Re: [electron/electron.atom.io] Add Jasper app (#352)')
|
||||
assert.equal(processed.body.includes(bodyPart), true)
|
||||
const bodyPart = `<p>In <a href="https://github.com/electron/electron.atom.io/pull/352#discussion_r67715160">_data/apps.yml</a>:</p>`
|
||||
|
||||
processMessage({message}).then((processed) => {
|
||||
expect(true).toBe(false)
|
||||
expect(processed.headers['in-reply-to']).toEqual('<electron/electron.atom.io/pull/352@github.com>')
|
||||
expect(processed.messageId).toEqual('<electron/electron.atom.io/pull/352/r67715160@github.com>')
|
||||
expect(processed.subject).toEqual('Re: [electron/electron.atom.io] Add Jasper app (#352)')
|
||||
expect(processed.body.includes(bodyPart)).toBe(true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
test()
|
||||
|
|
5
packages/nylas-message-processor/spec/run.js
Normal file
5
packages/nylas-message-processor/spec/run.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import Jasmine from 'jasmine'
|
||||
|
||||
const jasmine = new Jasmine()
|
||||
jasmine.loadConfigFile('spec/support/jasmine.json')
|
||||
jasmine.execute()
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"spec_dir": "spec",
|
||||
"spec_files": [
|
||||
"**/*-spec.js"
|
||||
],
|
||||
"helpers": [ ]
|
||||
}
|
Loading…
Reference in a new issue