diff --git a/packages/nylas-message-processor/package.json b/packages/nylas-message-processor/package.json index 0748d7c9d..d60b34a88 100644 --- a/packages/nylas-message-processor/package.json +++ b/packages/nylas-message-processor/package.json @@ -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"] } } diff --git a/packages/nylas-message-processor/spec/parsing-spec.js b/packages/nylas-message-processor/spec/parsing-spec.js index ac903a39d..0e0e99119 100644 --- a/packages/nylas-message-processor/spec/parsing-spec.js +++ b/packages/nylas-message-processor/spec/parsing-spec.js @@ -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 = `

In _data/apps.yml:

` - assert.equal(processed.headers['in-reply-to'], '') - assert.equal(processed.messageId, '') - assert.equal(processed.subject, 'Re: [electron/electron.atom.io] Add Jasper app (#352)') - assert.equal(processed.body.includes(bodyPart), true) + const bodyPart = `

In _data/apps.yml:

` + + processMessage({message}).then((processed) => { + expect(true).toBe(false) + expect(processed.headers['in-reply-to']).toEqual('') + expect(processed.messageId).toEqual('') + expect(processed.subject).toEqual('Re: [electron/electron.atom.io] Add Jasper app (#352)') + expect(processed.body.includes(bodyPart)).toBe(true) + done() }) }) - -test() diff --git a/packages/nylas-message-processor/spec/run.js b/packages/nylas-message-processor/spec/run.js new file mode 100644 index 000000000..4eb56830f --- /dev/null +++ b/packages/nylas-message-processor/spec/run.js @@ -0,0 +1,5 @@ +import Jasmine from 'jasmine' + +const jasmine = new Jasmine() +jasmine.loadConfigFile('spec/support/jasmine.json') +jasmine.execute() diff --git a/packages/nylas-message-processor/spec/support/jasmine.json b/packages/nylas-message-processor/spec/support/jasmine.json new file mode 100644 index 000000000..6a2e779f4 --- /dev/null +++ b/packages/nylas-message-processor/spec/support/jasmine.json @@ -0,0 +1,7 @@ +{ + "spec_dir": "spec", + "spec_files": [ + "**/*-spec.js" + ], + "helpers": [ ] +}