Git Product home page Git Product logo

equivalent-xml-js's Introduction

Equivalent XML JS Build status

Equivalent XML JS is designed to ease the process of testing XML output. The work is a port of equivalent-xml

  • Comparing text output is brittle due to the vagaries of serialization.
  • Attribute order doesn't matter.
  • Element order matters sometimes, but not always.
  • Text sometimes needs to be normalized, but CDATA doesn't.

Usage

> var doc1 = EquivalentXml.xml("<root><foo a='1' b='2'>Hello</foo><bar>World</bar></root>");
> var doc2 = EquivalentXml.xml("<root><bar>World</bar><foo b='2' a='1'> Hello </foo></root>");
> EquivalentXml.isEquivalent(doc1,doc2);
true
> EquivalentXml.isEquivalent(doc1,doc2, {element_order: true});
false
> EquivalentXml.isEquivalent(doc1,doc2, {normalize_whitespace: false});
false

Options

{element_order: true }

Require elements to be in the same relative position in order to be considered equivalent.

{normalize_whitespace: false }

Don't normalize whitespace within text nodes; require text nodes to match exactly.

Using with Jasmine

In your SpecHelper.js file add:

beforeEach(function() {
  this.addMatchers(EquivalentXml.jasmine);
});

Then in your tests you can write

 expect(node_1).beEquivalentTo(node_2);
 expect(node_1).not.beEquivalentTo(node_2);
 expect(node_1).beEquivalentTo(node_2,{element_order: true});

Install tools

If you want to test or build the source you will first need to install Ruby and Bundler. Once you have this:

$ bundle install

Building the source with dependencies

$ mkdir build
$ rake build

Tests

All of the tests are written in Jasmine. Sprockets is used to describe dependencies between the files. To start jasmine run:

$ rake jasmine

Open your browser to http://localhost:8888

If you want to run the tests directly in the console just type:

$ rake jasmine:ci
/Users/theo/.rvm/rubies/ruby-1.9.3-p0/bin/ruby -S rspec spec/javascripts/support/jasmine_runner.rb --colour --format progress
[2012-03-15 15:46:50] INFO  WEBrick 1.3.1
[2012-03-15 15:46:50] INFO  ruby 1.9.3 (2011-10-30) [x86_64-darwin11.1.0]
[2012-03-15 15:46:50] INFO  WEBrick::HTTPServer#start: pid=39919 port=63714
Waiting for jasmine server on 63714...
jasmine server started.
Waiting for suite to finish in browser ...
..........................................

Or you can check the current status of master using Travis

Supported platforms

It has been tested on:

  • Chrome 18
  • Safari 5
  • Firefox

equivalent-xml-js's People

Contributors

mbklein avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.