Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add several test cases for testing BigNumber Support
  • Loading branch information
SebastianG committed Feb 9, 2019
commit 44e63f4cffa589588a33838a4d6c73570c81fff7
20 changes: 20 additions & 0 deletions test/diff_test.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
BigNumber = require 'bignumber.js'
fs = require 'fs'
Path = require 'path'
assert = require 'assert'
Expand Down Expand Up @@ -178,3 +179,22 @@ describe 'diffString', ->

it "return an empty string when no diff found", ->
assert.equal diffString(a, a), ''


describe 'Big Number Support', ->

it "should handle a diff with different Big Number values", ->
assert.deepEqual { __old: BigNumber('3e+5000'), __new: BigNumber('98765432100123456789') }, diff(BigNumber('3e+5000'), BigNumber('98765432100123456789'), bigNumberSupport: true)

it "should handle a diff with equal Big Number values", ->
assert.deepEqual undefined, diff(BigNumber('3e+5000'), BigNumber('3e+5000'), bigNumberSupport: true)

it "should handle a diff for an array with Big Number values", ->
assert.deepEqual [['~', {__old: BigNumber('3e+5000'), __new: BigNumber('98765432100123456789')}], ['~', {__old: BigNumber('3e+6000'), __new: BigNumber('12345678901234567890')}]], diff([BigNumber('3e+5000'), BigNumber('3e+6000')], [BigNumber('98765432100123456789'), BigNumber('12345678901234567890')], bigNumberSupport: true)

it "should handle a diff when old value is an ordinary number and new value contains a Big Number value", ->
assert.deepEqual { __old: 1, __new: BigNumber('98765432100123456789') }, diff(1, BigNumber('98765432100123456789'), bigNumberSupport: true)

it "should handle a diff when old value contains a Big Number value and new value is an ordinary number", ->
assert.deepEqual { __old: BigNumber('3e+5000'), __new: 2}, diff(BigNumber('3e+5000'), 2, bigNumberSupport: true)