Skip to content

Commit

Permalink
Run tests with babel-node
Browse files Browse the repository at this point in the history
  • Loading branch information
legastero committed Nov 7, 2018
1 parent 577806d commit 4802407
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -120,7 +120,7 @@
"compile": "rimraf lib && babel --optional runtime -sd lib/ src/",
"lint": "eslint .",
"prepare": "npm run compile",
"test": "npm run compile && node test/index.js | tap-spec",
"test": "babel-node test/index.js | tap-spec",
"validate": "npm ls"
}
}
4 changes: 2 additions & 2 deletions test/auth/digest-md5.js
@@ -1,5 +1,5 @@
const test = require('tape');
const Mech = require('../../lib/sasl/digest-md5').default;
import test from 'tape';
import Mech from '../../src/sasl/digest-md5';

test('DIGEST-MD5', function(t) {
const mech = new Mech({
Expand Down
4 changes: 2 additions & 2 deletions test/auth/scram-sha-1.js
@@ -1,5 +1,5 @@
const test = require('tape');
const SCRAM = require('../../lib/sasl/scram-sha-1').default;
import test from 'tape';
import SCRAM from '../../src/sasl/scram-sha-1';

test('SCRAM', function(t) {
const mech = new SCRAM({
Expand Down
6 changes: 2 additions & 4 deletions test/connection.js
@@ -1,7 +1,5 @@
'use strict';

const test = require('tape');
const stanza = require('../lib');
import test from 'tape';
import * as stanza from '../src';

test('Connect using WebSocket', function(t) {
t.plan(1);
Expand Down
20 changes: 10 additions & 10 deletions test/hostmeta.js
@@ -1,10 +1,10 @@
'use strict';
import test from 'tape';
import jxt from 'jxt';

const test = require('tape');
const JXT = require('jxt').createRegistry();
import { getHostMeta } from '../src/plugins/hostmeta';
import XRD from '../src/protocol/stanzas/xrd';

const HostMeta = require('../lib/plugins/hostmeta');
const XRD = require('../lib/protocol/stanzas/xrd');
const JXT = jxt.createRegistry();

const xml =
'<?xml version="1.0" encoding="UTF-8"?>' +
Expand Down Expand Up @@ -63,7 +63,7 @@ const json = {
test('XRD', function(t) {
t.plan(4);

JXT.use(XRD.default);
JXT.use(XRD);

const xrd = JXT.parse(xml).toJSON();

Expand All @@ -77,7 +77,7 @@ test('XRD', function(t) {
test('retrieve JSON only', function(t) {
t.plan(2);

HostMeta.getHostMeta(
getHostMeta(
JXT,
{
host: 'lance.im',
Expand All @@ -95,7 +95,7 @@ test('retrieve JSON only', function(t) {
test('retrieve XRD only', function(t) {
t.plan(2);

HostMeta.getHostMeta(
getHostMeta(
JXT,
{
host: 'lance.im',
Expand All @@ -111,14 +111,14 @@ test('retrieve XRD only', function(t) {
});

test('retrieve either', function(t) {
HostMeta.getHostMeta(JXT, 'lance.im', function(err, hostmeta) {
getHostMeta(JXT, 'lance.im', function(err, hostmeta) {
t.ok(hostmeta.links.length > 0);
t.end();
});
});

test('missing host-meta', function(t) {
HostMeta.getHostMeta(
getHostMeta(
JXT,
{
host: 'dne.lance.im',
Expand Down
10 changes: 5 additions & 5 deletions test/index.js
@@ -1,12 +1,12 @@
// Generic Connection Tests
require('./connection');
import './connection';

// Stanza Support Tests
require('./stanza-dataforms');
import './stanza-dataforms';

// Host-meta Tests
require('./hostmeta');
import './hostmeta';

// Auth Mechanism Tests
require('./auth/digest-md5');
require('./auth/scram-sha-1');
import './auth/digest-md5';
import './auth/scram-sha-1';
28 changes: 15 additions & 13 deletions test/stanza-dataforms.js
@@ -1,11 +1,13 @@
const fs = require('fs');
const jxt = require('jxt').createRegistry();
const test = require('tape');
const JID = require('xmpp-jid').JID;
import jxt from 'jxt';
import { JID } from 'xmpp-jid';
import * as fs from 'fs';
import test from 'tape';

jxt.use(require('../lib/protocol').default);
const JXT = jxt.createRegistry();

const DataForm = jxt.getDefinition('x', 'jabber:x:data');
JXT.use(require('../lib/protocol').default);

const DataForm = JXT.getDefinition('x', 'jabber:x:data');

const formXML = fs.readFileSync(__dirname + '/samples/dataform-1.xml');
const submittedXML = fs.readFileSync(__dirname + '/samples/dataform-2.xml');
Expand All @@ -16,7 +18,7 @@ const layoutXML = fs.readFileSync(__dirname + '/samples/dataform-6.xml');
const nestedLayoutXML = fs.readFileSync(__dirname + '/samples/dataform-7.xml');

test('Convert Form XML to Data Form object', function(t) {
const form = jxt.parse(formXML, DataForm).toJSON();
const form = JXT.parse(formXML, DataForm).toJSON();

t.equal(form.type, 'form');
t.equal(form.title, 'Bot Configuration');
Expand Down Expand Up @@ -114,7 +116,7 @@ test('Convert Form XML to Data Form object', function(t) {
});

test('Convert Form Submission Results XML to Data Form object', function(t) {
let form = jxt.parse(submittedXML, DataForm).toJSON();
let form = JXT.parse(submittedXML, DataForm).toJSON();

// Clients are required to send the type attribute back when
// submitting forms, so we have to apply the type values back
Expand Down Expand Up @@ -193,7 +195,7 @@ test('Convert Form Submission Results XML to Data Form object', function(t) {
});

test('Convert Form Item Results XML to Data Form object', function(t) {
const form = jxt.parse(itemsXML, DataForm).toJSON();
const form = JXT.parse(itemsXML, DataForm).toJSON();

t.equal(form.type, 'result');
t.equal(form.title, 'Joogle Search: verona');
Expand Down Expand Up @@ -228,7 +230,7 @@ test('Convert Form Item Results XML to Data Form object', function(t) {
});

test('Convert Form with Validation XML to Data Form object', function(t) {
const form = jxt.parse(validationXML, DataForm).toJSON();
const form = JXT.parse(validationXML, DataForm).toJSON();

t.equal(form.fields.length, 5);

Expand Down Expand Up @@ -304,7 +306,7 @@ test('Convert Form with Validation XML to Data Form object', function(t) {
});

test('Convert Form with Media Field XML to Data Form object', function(t) {
const form = jxt.parse(mediaXML, DataForm).toJSON();
const form = JXT.parse(mediaXML, DataForm).toJSON();

t.equal(form.fields.length, 1);

Expand All @@ -331,7 +333,7 @@ test('Convert Form with Media Field XML to Data Form object', function(t) {
});

test('Form layout', function(t) {
const form = jxt.parse(layoutXML, DataForm).toJSON();
const form = JXT.parse(layoutXML, DataForm).toJSON();

t.same(form.layout, [
{
Expand Down Expand Up @@ -381,7 +383,7 @@ test('Form layout', function(t) {
});

test('Form layout with nested sections', function(t) {
const form = jxt.parse(nestedLayoutXML, DataForm).toJSON();
const form = JXT.parse(nestedLayoutXML, DataForm).toJSON();

t.same(form.layout, [
{
Expand Down

0 comments on commit 4802407

Please sign in to comment.