reconstruct comparison object. Qiu

This commit is contained in:
Wang Qiu
2013-07-28 17:50:01 +08:00
parent 2d714dacc9
commit 06a9f741cb
4 changed files with 52 additions and 21 deletions

View File

@@ -11,7 +11,10 @@ module.exports =
build: 'abcd'
prod: 'efgh'
@diffObj =
@diffObj =
isSameDimensions: true
misMatchPercentage: "2.84"
analysisTime: 54
getImageDataUrl: () ->
'ABCD'
@@ -28,8 +31,8 @@ module.exports =
callback()
'it should have correct properties': (test) ->
test.equals @comparison.build, 'abcd'
test.equals @comparison.prod, 'efgh'
test.equals @comparison.images.build, 'abcd'
test.equals @comparison.images.prod, 'efgh'
test.done()
@@ -38,6 +41,13 @@ module.exports =
@comparison.diff callback
test.ok callback.calledOnce
test.equals @comparison.DIFF, 'ABCD'
test.equals @comparison.images.diff, 'ABCD'
test.done()
'it should get correct diff property': (test) ->
@comparison.diff =>
test.ok @comparison.isSameDimensions
test.strictEqual @comparison.misMatchPercentage, 2.84
test.equals @comparison.analysisTime, 54
test.done()

View File

@@ -6,21 +6,37 @@ module.exports =
@compares =
chrome:
'/404.html':
build: 'aaa'
prod: 'bbb'
isSameDimensions: true
misMatchPercentage: 2.5
analysisTime: 51
images:
build: 'aaa'
prod: 'bbb'
'/strict-mode':
build: 'ccc'
prod: 'ddd'
isSameDimensions: false
misMatchPercentage: 4
analysisTime: 52
images:
build: 'ccc'
prod: 'ddd'
firefox:
'/404.html':
build: 'eee'
prod: 'fff'
isSameDimensions: true
misMatchPercentage: 3
analysisTime: 53
images:
build: 'eee'
prod: 'fff'
'/strict-mode':
build: 'ggg'
prod: 'hhh'
images:
isSameDimensions: false
misMatchPercentage: 9
analysisTime: 54
build: 'ggg'
prod: 'hhh'
callback()
tearDown: (callback) ->
@@ -30,7 +46,7 @@ module.exports =
html = reporter.generate 'html', @compares
test.ok html.indexOf('<h2>chrome</h2>') > 0
test.ok html.indexOf('<h3>/404.html</h3>') > 0
test.ok html.indexOf('<h3>/404.html 53ms</h3>') > 0
test.ok html.indexOf('data:image/png;base64,ggg') > 0
test.ok html.indexOf('data-env="build"') > 0
test.done()
@@ -40,6 +56,6 @@ module.exports =
json = JSON.parse jsonStr
test.ok _.isEqual _.keys(json), ['chrome', 'firefox']
test.ok _.isEqual _.keys(json.chrome['/404.html']), ['build', 'prod']
test.ok _.isEqual _.values(json.chrome['/404.html']), ['aaa', 'bbb']
test.ok _.isEqual _.keys(json.chrome['/404.html'].images), ['build', 'prod']
test.ok _.isEqual _.values(json.chrome['/404.html'].images), ['aaa', 'bbb']
test.done()