From ae89c0475d6c4ba0864178cb30ac1649af6d91af Mon Sep 17 00:00:00 2001 From: stereobooster Date: Mon, 14 May 2012 11:10:36 +0300 Subject: [PATCH] move tests to external files, so they can be launched on the server-side --- tests/index.html | 575 +---------------------------------------- tests/lint-tests.html | 49 +--- tests/lint_test.js | 52 ++++ tests/minify_test.js | 577 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 638 insertions(+), 615 deletions(-) create mode 100644 tests/lint_test.js create mode 100644 tests/minify_test.js diff --git a/tests/index.html b/tests/index.html index 2b66529..a51712e 100644 --- a/tests/index.html +++ b/tests/index.html @@ -5,582 +5,15 @@ - - - + + + -

HTML Minifier

    - - + \ No newline at end of file diff --git a/tests/lint-tests.html b/tests/lint-tests.html index d121159..f9fe51b 100644 --- a/tests/lint-tests.html +++ b/tests/lint-tests.html @@ -5,55 +5,16 @@ - - - - + + + + -

    HTML Lint

      - - + \ No newline at end of file diff --git a/tests/lint_test.js b/tests/lint_test.js new file mode 100644 index 0000000..d819c76 --- /dev/null +++ b/tests/lint_test.js @@ -0,0 +1,52 @@ +(function(global){ + + var minify, QUnit, + test, equals, ok, + input, output, HTMLLint, lint; + + if (typeof require === 'function') { + QUnit = require('./qunit'); + minify = require('../src/htmlminifier').minify; + HTMLLint = require('../src/htmllint').HTMLLint; + } else { + QUnit = global.QUnit; + minify = global.minify; + HTMLLint = global.HTMLLint; + } + + test = QUnit.test; + equals = QUnit.equals; + ok = QUnit.ok; + + QUnit.module('', { + setup: function() { + lint = new HTMLLint(); + } + }); + + test('lint exists', function() { + ok(typeof lint !== 'undefined'); + }); + + test('lint is instance of HTMLLint', function() { + ok(lint instanceof HTMLLint); + }); + + test('lint API', function() { + equals(0, lint.log.length, '`log` property exists'); + equals("function", typeof lint.populate, '`populate` method exists'); + equals("function", typeof lint.test, '`test` method exists'); + equals("function", typeof lint.testElement, '`testElement` method exists'); + equals("function", typeof lint.testAttribute, '`testAttribute` method exists'); + }); + + test('deprecated element (font)', function(){ + minify('foo', { lint: lint }); + var log = lint.log.join(''); + + ok(log.indexOf('font') > -1); + ok(log.indexOf('deprecated') > -1); + ok(log.indexOf('element') > -1); + }); + +}(this)); \ No newline at end of file diff --git a/tests/minify_test.js b/tests/minify_test.js new file mode 100644 index 0000000..7cebc6d --- /dev/null +++ b/tests/minify_test.js @@ -0,0 +1,577 @@ +(function(global){ + + var minify, QUnit, + test, equals, ok, + input, output; + + if (typeof require === 'function') { + QUnit = require('./qunit'); + minify = require('../src/htmlminifier').minify; + } else { + QUnit = global.QUnit; + minify = global.minify; + } + + test = QUnit.test; + equals = QUnit.equals; + ok = QUnit.ok; + + test('parsing non-trivial markup', function() { + equals(minify('

      x

      '), '

      x

      '); + equals(minify('

      x

      '), '

      x

      '); + equals(minify('

      x

      '), '

      x

      '); + equals(minify('

      xxx

      '), '

      xxx

      '); + equals(minify('

      xxx

      '), '

      xxx

      '); + + input = '
      '+ + 'i\'m 10 levels deep'+ + '
      '; + + equals(minify(input), input); + + equals(minify('