Permalink
Browse files

Run tests with babel-node

  • Loading branch information...
legastero committed Nov 7, 2018
1 parent 577806d commit 48024074a97ea5b1faa648ee7d29ea381c06c67c
Showing with 37 additions and 37 deletions.
  1. +1 −1 package.json
  2. +2 −2 test/auth/digest-md5.js
  3. +2 −2 test/auth/scram-sha-1.js
  4. +2 −4 test/connection.js
  5. +10 −10 test/hostmeta.js
  6. +5 −5 test/index.js
  7. +15 −13 test/stanza-dataforms.js
@@ -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"
}
}
@@ -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({
@@ -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({
@@ -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);
@@ -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"?>' +
@@ -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();
@@ -77,7 +77,7 @@ test('XRD', function(t) {
test('retrieve JSON only', function(t) {
t.plan(2);
HostMeta.getHostMeta(
getHostMeta(
JXT,
{
host: 'lance.im',
@@ -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',
@@ -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',
@@ -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';
@@ -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');
@@ -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');
@@ -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
@@ -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');
@@ -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);
@@ -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);
@@ -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, [
{
@@ -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, [
{

0 comments on commit 4802407

Please sign in to comment.