Skip to content

Commit

Permalink
use mocha and chai instead of buster
Browse files Browse the repository at this point in the history
  • Loading branch information
flosse committed Dec 19, 2014
1 parent 881912e commit c6361c1
Show file tree
Hide file tree
Showing 11 changed files with 234 additions and 231 deletions.
9 changes: 0 additions & 9 deletions joap/Cakefile

This file was deleted.

17 changes: 2 additions & 15 deletions joap/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,8 @@ aClass.subscribe successHandler, changeHandler, {bare:true}

- [node-xmpp-joap](https://github.com/flosse/node-xmpp-joap)

## Tests & specs

[buster.js](https://github.com/busterjs/) and
[buster-coffee](https://github.com/jodal/buster-coffee) and
are required (`npm install -g buster buster-coffee`) for running the tests.

First start a test server

```bash
buster server
```

Then navigate with one or more browsers to `localhost:1111` and capture them.
Afterwards you can run the specs:
## Run tests

```bash
cake test
npm i && npm test
```
23 changes: 0 additions & 23 deletions joap/buster.js

This file was deleted.

2 changes: 1 addition & 1 deletion joap/jid.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is coffee-script fork of
https://github.com/astro/node-xmpp/blob/master/lib/xmpp/jid.js
###

toUnicode = punycode?.toUnicode or (a) -> a
toUnicode = punycode?.toUnicode or (a) -> a

class JID

Expand Down
44 changes: 44 additions & 0 deletions joap/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = function(cfg){

cfg.set({

basePath: '',

files: [
'node_modules/punycode/punycode.js',
'node_modules/strophe/strophe.js',
'../rpc/strophe.rpc.js',
'jid.js',
'strophe.joap.js',
'node_modules/chai/chai.js',
'node_modules/sinon-chai/lib/sinon-chai.js',
'node_modules/sinon/pkg/sinon.js',
'node_modules/jquery/dist/jquery.js',
'spec/*.spec.coffee'
],

frameworks: ["mocha"],

reporters: ['progress'],

port: 9876,

runnerPort: 9100,

colors: true,

logLevel: cfg.LOG_INFO,

autoWatch: false,

browsers: ['PhantomJS'],

captureTimeout: 6000,

singleRun: true,

preprocessors: {
'spec/*.coffee': ['coffee']
}

});};
20 changes: 15 additions & 5 deletions joap/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "strophe-joap",
"version": "0.0.1",
"version": "0.0.2",
"description": "XEP-0075 (JOAP) plugin for strophe.js",
"main": "strophe.joap.js",
"scripts": {
"lint": "coffeelint *.coffee",
"test": "cake test"
"test": "npm run lint && node_modules/karma/bin/karma start"
},
"repository": {
"type": "git",
Expand All @@ -25,9 +25,19 @@
},
"homepage": "https://github.com/strophe/strophejs-plugins",
"devDependencies": {
"buster": "~0.7.8",
"buster-coffee": "~0.1.4",
"chai": "^1.10.0",
"coffee-script": "~1.8.0",
"coffeelint": "^1.7.1"
"coffeelint": "^1.7.1",
"jquery": "^2.1.3",
"karma": "^0.12.28",
"karma-coffee-preprocessor": "^0.2.1",
"karma-mocha": "^0.1.10",
"karma-phantomjs-launcher": "^0.1.4",
"mocha": "^2.0.1",
"phantomjs": "^1.9.12",
"punycode": "^1.3.2",
"sinon": "^1.12.2",
"sinon-chai": "^2.6.0",
"strophe": "^1.1.3-1"
}
}
1 change: 0 additions & 1 deletion joap/spec/browserSetup.coffee

This file was deleted.

87 changes: 41 additions & 46 deletions joap/spec/jid.spec.coffee
Original file line number Diff line number Diff line change
@@ -1,96 +1,91 @@
buster.spec.expose()

if require?
JID = require('./../lib/xmpp').JID
else if window?
JID = window.JID
assert = chai.assert

describe 'JID', ->

describe 'parsing', ->

it 'should parse a "domain" JID', ->
j = new JID 'd'
assert.equals j.user, null
assert.equals j.domain, 'd'
assert.equals j.resource, null
assert.equal j.user, null
assert.equal j.domain, 'd'
assert.equal j.resource, null

it 'should parse a "user@domain" JID', ->
j = new JID('u@d')
assert.equals(j.user, 'u')
assert.equals(j.domain, 'd')
assert.equals(j.resource, null)
j = new JID 'u@d'
assert.equal j.user, 'u'
assert.equal j.domain, 'd'
assert.equal j.resource, null

it 'should parse a "domain/resource" JID', ->
j = new JID('d/r')
assert.equals(j.user, null)
assert.equals(j.domain, 'd')
assert.equals(j.resource, 'r')
assert.equal(j.user, null)
assert.equal(j.domain, 'd')
assert.equal(j.resource, 'r')

it 'should parse a "user@domain/resource" JID', ->
j = new JID 'u@d/r'
assert.equals(j.user, 'u')
assert.equals(j.domain, 'd')
assert.equals(j.resource, 'r')
assert.equal(j.user, 'u')
assert.equal(j.domain, 'd')
assert.equal(j.resource, 'r')

it 'should parse an internationalized domain name as unicode', ->
j = new JID('öko.de')
assert.equals(j.domain, 'öko.de')
assert.equal(j.domain, 'öko.de')

it 'should parse an internationalized domain name as ascii/punycode', ->
j = new JID 'xn--ko-eka.de'
assert.equals j.domain, 'öko.de'
assert.equal j.domain, 'öko.de'

it 'should parse a JID with punycode', ->
j = new JID('Сергей@xn--lsa92diaqnge.xn--p1ai')
assert.equals j.user, 'сергей'
assert.equals j.domain, 'приме́р.рф'
assert.equal j.user, 'сергей'
assert.equal j.domain, 'приме́р.рф'

describe 'serialization', ->
it 'should serialize a "domain" JID', ->
j = new JID(null, 'd')
assert.equals(j.toString(), 'd')
assert.equal(j.toString(), 'd')

it 'should serialize a "user@domain" JID', ->
j = new JID('u', 'd')
assert.equals(j.toString(), 'u@d')
assert.equal(j.toString(), 'u@d')

it 'should serialize a "domain/resource" JID', ->
j = new JID(null, 'd', 'r')
assert.equals(j.toString(), 'd/r')
assert.equal(j.toString(), 'd/r')

it 'should serialize a "user@domain/resource" JID', ->
j = new JID('u', 'd', 'r')
assert.equals(j.toString(), 'u@d/r')
j = new JID 'u', 'd', 'r'
assert.equal j.toString(), 'u@d/r'

describe 'equality', ->

it 'should parsed JIDs should be equal', ->
j1 = new JID('foo@bar/baz')
j2 = new JID('foo@bar/baz')
assert.equals(j1.equals(j2), true)
j1 = new JID 'foo@bar/baz'
j2 = new JID 'foo@bar/baz'
assert.equal j1.equals(j2), yes

it 'should parsed JIDs should be not equal', ->
j1 = new JID('foo@bar/baz')
j2 = new JID('quux@bar/baz')
assert.equals(j1.equals(j2), false)
j1 = new JID 'foo@bar/baz'
j2 = new JID 'quux@bar/baz'
assert.equal j1.equals(j2), no

it 'should should ignore case in user', ->
j1 = new JID('foo@bar/baz')
j2 = new JID('FOO@bar/baz')
assert.equals(j1.equals(j2), true)
j1 = new JID 'foo@bar/baz'
j2 = new JID 'FOO@bar/baz'
assert.equal j1.equals(j2), yes

it 'should should ignore case in domain', ->
j1 = new JID('foo@bar/baz')
j2 = new JID('foo@BAR/baz')
assert.equals(j1.equals(j2), true)
j1 = new JID 'foo@bar/baz'
j2 = new JID 'foo@BAR/baz'
assert.equal(j1.equals(j2), true)

it 'should should not ignore case in resource', ->
j1 = new JID('foo@bar/baz')
j2 = new JID('foo@bar/Baz')
assert.equals(j1.equals(j2), false)
j1 = new JID 'foo@bar/baz'
j2 = new JID 'foo@bar/Baz'
assert.equal j1.equals(j2), no

it 'should should ignore international caseness', ->
j1 = new JID('föö@bär/baß')
j2 = new JID('fÖö@BÄR/baß')
assert.equals(j1.equals(j2), true)
j1 = new JID 'föö@bär/baß'
j2 = new JID 'fÖö@BÄR/baß'
assert.equal j1.equals(j2), yes
Loading

0 comments on commit c6361c1

Please sign in to comment.