npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

seedl-jasmine-saxon

v0.1.3

Published

Testing XSLT, XPATH and Xquery code as part of jasmine tests

Downloads

5

Readme

SeedL Jasmine Saxon

This library helps to test your XSLT, XPATH and Xquery code when using the jasmine testing framework. To use the library you have to install the BaseX database system, first.

Features

The library provides functions to execute XSLT, XPATH and Xquery scripts. You can upload test data before to set up your testing environment. Further, there are library functions to ease the evaluation of the result, which will be checked as part of an assert:

  • noSpaces remove all space characters and new lines from the result string
  • noHeader remove the encoded XML header

Getting started

  • copy basex-example.json to basex.json and enter your personal configuration.

  • install BaseX and start it in the background, e.g. basexserver -S -z on the command line

  • install node.js from http://nodejs.org

  • npm install seedl-jasmine-saxon

  • npm install jasmine-matchers

  • npm install jasmine-given

  • npm install jasmine-node

or include the libraries in your package.json file in the devDependencies section (see source)

Usage

require 'jasmine-matchers'
require 'jasmine-given'

sjs = require('seedl-jasmine-saxon')
processor = sjs.Basex
noSpaces = sjs.noSpaces
noHeader = sjs.noHeader

debug = true

And the tests...

describe 'the basex xslt interface testing script variations', ->

  beforeEach (done) ->
    new processor().setup ->
      done()
    , 'example', '''<?xml version="1.0" encoding="UTF-8"?>
        <data>
          <value>Hello my World!</value>
        </data>'''

  it 'should execute a xslt script', (done) ->
    new processor().xslt done, '''
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
        <xsl:template match="/">
          <xsl:value-of select="data/value/text()" />
        </xsl:template>
      </xsl:stylesheet>
      ''', 'fn:doc("example")', (err, reply) ->
        expect(reply.ok).toBe true
        expect(noHeader(noSpaces(reply.result))).toBe 'HellomyWorld!'

describe 'the basex xslt interface testing data variations', ->

  beforeEach (done) ->
    new processor().setup ->
      done()
    , 'script', '''
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
        <xsl:template match="/">
          <xsl:value-of select="data/value/text()" />
        </xsl:template>
      </xsl:stylesheet>
    '''

  it 'should execute test data', (done) ->
    new processor().xslt done, 'fn:doc("script")', '''<data>
        <value>Hello my World!</value>
      </data>
      ''', (err, reply) ->
        expect(reply.ok).toBe true
        expect(noHeader(noSpaces(reply.result))).toBe 'HellomyWorld!'

describe 'the basex xpath interface', ->

  beforeEach (done) ->
    new processor().setup ->
      done()
    , 'example', '''<?xml version="1.0" encoding="UTF-8"?>
        <data>
          <value>Hello my World!</value>
        </data>
      '''

Here is an example how to output debugging information.

  it 'should execute xpath test with data', (done) ->
    new processor().xpath done, 'fn:doc("example")//value', (err, reply) ->
        expect(reply.ok).toBe true
        expect(noSpaces(reply.result)).toBe '<value>HellomyWorld!</value>'
    , debug

  it 'should execute xpath test without data', (done) ->
    new processor().xpath done, '(1 to 20)[. mod 5 eq 0]', (err, reply) ->
        expect(reply.ok).toBe true
        expect(noSpaces(reply.result)).toBe '5101520'