var test = require('tape');
var postcss = require('postcss');
var plugin = require('./');
var name = require('./package.json').name;

var tests = [
  {
    should: 'scope selectors',
    input: '.foobar {}',
    expected: '.local[foobar] {}'
  },
  {
    should: 'scope multiple selectors',
    input: '.foo, .baz {}',
    expected: '.local[foo], .local[baz] {}'
  },
  {
    should: 'scope sibling selectors',
    input: '.foo ~ .baz {}',
    expected: '.local[foo] ~ .local[baz] {}'
  },
  {
    should: 'scope psuedo elements',
    input: '.foo:after {}',
    expected: '.local[foo]:after {}'
  }
];

function process (css, options) {
    return postcss(plugin(options)).process(css).css;
}

test(name, function (t) {
    t.plan(tests.length);

    tests.forEach(function (test) {
        var options = test.options || {};
        t.equal(process(test.input, options), test.expected, 'should ' + test.should);
    });
});

test('should use the postcss plugin api', function (t) {
    t.plan(2);
    t.ok(plugin().postcssVersion, 'should be able to access version');
    t.equal(plugin().postcssPlugin, name, 'should be able to access name');
});

@@ -589,16 +589,159 @@
 ter %7B%7D'%0A
+  %7D,%0A  %7B%0A    should: 'scope media queries',%0A    input: '@media only screen %7B .foo %7B%7D %7D',%0A    expected: '@media only screen %7B .local%5Bfoo%5D %7B%7D %7D'%0A
   %7D%0A%5D;%0A%0A

Add test for media queries