Sha256: 24f573f6113baacb68d0618e2923d9c2534417a8abbc3ae56eb9f57840a0b81d

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

import re
import unittest
import jsbeautifier

class TestJSBeautifierIndentation(unittest.TestCase):
    def test_tabs(self):
        test_fragment = self.decodesto

        self.options.indent_with_tabs = 1;
        test_fragment('{tabs()}', "{\n\ttabs()\n}");

    def test_function_indent(self):
        test_fragment = self.decodesto

        self.options.indent_with_tabs = 1;
        self.options.keep_function_indentation = 1;
        test_fragment('var foo = function(){ bar() }();', "var foo = function() {\n\tbar()\n}();");

        self.options.tabs = 1;
        self.options.keep_function_indentation = 0;
        test_fragment('var foo = function(){ baz() }();', "var foo = function() {\n\t\tbaz()\n\t}();");

    def decodesto(self, input, expectation=None):
        self.assertEqual(
            jsbeautifier.beautify(input, self.options), expectation or input)

    @classmethod
    def setUpClass(cls):
        options = jsbeautifier.default_options()
        options.indent_size = 4
        options.indent_char = ' '
        options.preserve_newlines = True
        options.jslint_happy = False
        options.keep_array_indentation = False
        options.brace_style = 'collapse'
        options.indent_level = 0

        cls.options = options
        cls.wrapregex = re.compile('^(.+)$', re.MULTILINE)


if __name__ == '__main__':
    unittest.main()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
js-beautify-0.1.8 js-beautify-copy/python/jsbeautifier/tests/testindentation.py
js-beautify-0.1.7 js-beautify-copy/python/jsbeautifier/tests/testindentation.py