From ddc71dcb06dd7591d7b44574008daec088b3c91e Mon Sep 17 00:00:00 2001 From: Wang Qiu Date: Wed, 13 Nov 2013 23:02:01 +0800 Subject: [PATCH] remove report --- Gruntfile.js | 3 -- src/html.report.template.coffee | 61 ---------------------- src/index.coffee | 1 - src/reporter.coffee | 43 ---------------- test/src/reporter_test.coffee | 90 --------------------------------- 5 files changed, 198 deletions(-) delete mode 100644 src/html.report.template.coffee delete mode 100644 src/reporter.coffee delete mode 100644 test/src/reporter_test.coffee diff --git a/Gruntfile.js b/Gruntfile.js index f81f5f6..ce504e5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -14,15 +14,12 @@ module.exports = function(grunt) { 'lib/viff.js': 'src/viff.coffee', 'lib/comparison.js': 'src/comparison.coffee', 'lib/index.js': 'src/index.coffee', - 'lib/reporter.js': 'src/reporter.coffee', 'lib/color.helper.js': 'src/color.helper.coffee', - 'lib/html.report.template.js': 'src/html.report.template.coffee', 'lib/process.argv.js': 'src/process.argv.coffee', 'lib/image.generator.js': 'src/image.generator.coffee', 'lib/console.status.js': 'src/console.status.coffee', 'test/build/comparison_test.js': 'test/src/comparison_test.coffee', 'test/build/viff_test.js': 'test/src/viff_test.coffee', - 'test/build/reporter_test.js': 'test/src/reporter_test.coffee', 'test/build/process_argv_test.js': 'test/src/process_argv_test.coffee', 'test/build/image_generator_test.js': 'test/src/image_generator_test.coffee' } diff --git a/src/html.report.template.coffee b/src/html.report.template.coffee deleted file mode 100644 index b63c210..0000000 --- a/src/html.report.template.coffee +++ /dev/null @@ -1,61 +0,0 @@ - -template = """ - - - - - Viff Report - - - -

Viff Report - ({{sameCount}} same in {{caseCount}} cases) {{totalAnalysisTime}}ms

- {{#each compares}} -

{{@key}}

- - {{/each}} - - -""" - -module.exports = template \ No newline at end of file diff --git a/src/index.coffee b/src/index.coffee index a0b063a..b046c34 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -2,7 +2,6 @@ _ = require 'underscore' require 'webdriver-helper' Viff = require './viff.js' -Reporter = require './reporter.js' processArgs = require './process.argv.js' consoleStatus = require './console.status.js' imgGen = require './image.generator' diff --git a/src/reporter.coffee b/src/reporter.coffee deleted file mode 100644 index 748f1fd..0000000 --- a/src/reporter.coffee +++ /dev/null @@ -1,43 +0,0 @@ -require './color.helper.js' -_ = require 'underscore' -handlebars = require 'handlebars' -template = require './html.report.template.js' -ImageGenerator = require './image.generator.js' - -render = handlebars.compile template - -class Reporter - constructor: (@compares) -> - @cases = [] - @differences = [] - @totalAnalysisTime = 0 - - for browser, urls of @compares - for url, diff of urls - diffCase = {} - diffCase[url] = diff - - @cases.push diffCase - @differences.push(diffCase) if diff.misMatchPercentage isnt 0 - @totalAnalysisTime += diff.analysisTime - - @caseCount = @cases.length - @diffCount = @differences.length - - to: (format = 'html') -> - reportObj = - compares: @compares - caseCount: @caseCount - sameCount: @caseCount - @diffCount - diffCount: @diffCount - totalAnalysisTime: @totalAnalysisTime - - return render reportObj if format is 'html' - return JSON.stringify(reportObj) if format is 'json' - - if format is 'file' - ImageGenerator.generate reportObj - return '' - - -module.exports = Reporter \ No newline at end of file diff --git a/test/src/reporter_test.coffee b/test/src/reporter_test.coffee deleted file mode 100644 index 51e7c75..0000000 --- a/test/src/reporter_test.coffee +++ /dev/null @@ -1,90 +0,0 @@ -_ = require 'underscore' -sinon = require 'sinon' -Reporter = require '../../lib/reporter.js' -ImageGenerator = require '../../lib/image.generator.js' - -module.exports = - setUp: (callback) -> - @compares = - chrome: - '/404.html': - isSameDimensions: true - misMatchPercentage: 2.5 - analysisTime: 51 - images: - build: 'aaa' - prod: 'bbb' - - '/strict-mode': - isSameDimensions: false - misMatchPercentage: 4 - analysisTime: 52 - images: - build: 'ccc' - prod: 'ddd' - - firefox: - '/404.html': - isSameDimensions: true - misMatchPercentage: 3 - analysisTime: 53 - images: - build: 'eee' - prod: 'fff' - - '/strict-mode': - isSameDimensions: false - misMatchPercentage: 0 - analysisTime: 54 - images: - build: 'ggg' - prod: 'hhh' - - callback() - tearDown: (callback) -> - callback() - - 'it should contains 4 diffs': (test) -> - reporter = new Reporter @compares - test.equals reporter.caseCount, 4 - test.done() - - 'it should count how mamy diff is there': (test) -> - reporter = new Reporter @compares - test.equals reporter.diffCount, 3 - test.done() - - 'it should return total analysisTime': (test) -> - reporter = new Reporter @compares - test.equals reporter.totalAnalysisTime, 210 - test.done() - - 'it should generate correct html': (test) -> - html = new Reporter(@compares).to 'html' - - test.ok html.indexOf('

chrome

') > 0 - test.ok html.indexOf('

/404.html - 3% mismatch 53ms

') > 0 - test.ok html.indexOf('data:image/png;base64,ggg') > 0 - test.ok html.indexOf('data-env="build"') > 0 - test.ok html.indexOf('

Viff Report - (1 same in 4 cases) 210ms

') > 0 - test.done() - - 'it should generate correct json': (test) -> - jsonStr = new Reporter(@compares).to 'json' - json = JSON.parse jsonStr - - test.equals json.caseCount, 4 - test.equals json.diffCount, 3 - test.equals json.totalAnalysisTime, 210 - test.ok _.isEqual _.keys(json.compares), ['chrome', 'firefox'] - test.ok _.isEqual _.keys(json.compares.chrome['/404.html'].images), ['build', 'prod'] - test.ok _.isEqual _.values(json.compares.chrome['/404.html'].images), ['aaa', 'bbb'] - test.done() - - 'it should generate correct file-based json': (test) -> - generate = sinon.stub(ImageGenerator, 'generate').returns 'undefined' - new Reporter(@compares).to 'file' - - test.ok generate.calledOnce - test.equals generate.lastCall.args[0].compares, @compares - test.done()