Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

orderbookchanges-test.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict'
  2. var assert = require('assert-diff')
  3. var parseOrderbookChanges = require('../src/index').parseOrderbookChanges
  4. var fixtures = require('./fixtures/orderbookchanges.js')
  5. var orderWithExpiration = require('./fixtures/order-with-expiration.json')
  6. var orderWithExpirationResult =
  7. require('./fixtures/order-with-expiration-parsed.json')
  8. describe('parseOrderbookChanges', function() {
  9. it('parse OfferCreate -- consumed and partially consumed offer', function() {
  10. var meta = fixtures.offerCreateConsumedOffer().meta
  11. var expected = fixtures.parsedOfferCreate()
  12. assert.deepEqual(parseOrderbookChanges(meta), expected)
  13. })
  14. it('parse OfferCreate -- created offer', function() {
  15. var meta = fixtures.offerCreateCreatedOffer().meta
  16. var expected = fixtures.parsedOfferCreateCreated()
  17. assert.deepEqual(parseOrderbookChanges(meta), expected)
  18. })
  19. it('parse OfferCancel', function() {
  20. var meta = fixtures.offerCancel().meta
  21. var expected = fixtures.parsedOfferCancel()
  22. assert.deepEqual(parseOrderbookChanges(meta), expected)
  23. })
  24. it('parse OfferCreate -- consumed offer, no changes to TakerGets',
  25. function() {
  26. var meta = fixtures.offerCreateNoChangeTakerGets().meta
  27. var expected = fixtures.parsedOfferCreateNoChangeTakerGets()
  28. assert.deepEqual(parseOrderbookChanges(meta), expected)
  29. })
  30. it('order with expiration', function() {
  31. var meta = orderWithExpiration.meta
  32. var expected = orderWithExpirationResult
  33. assert.deepEqual(parseOrderbookChanges(meta), expected)
  34. })
  35. })