/*global describe, it*/
var expect = require('./unexpected-with-plugins'),
    query = require('../lib').query;

describe('query', function () {
    it('it should throw on error conditions', function (done) {
        expect(function andUndefined() { query.and(); }, 'to throw');
        expect(function andSingle() { query.and({}); }, 'to throw');

        expect(function orUndefined() { query.or(); }, 'to throw');
        expect(function orSingle() { query.or({}); }, 'to throw');

        expect(function notDouble() { query.not({}, {}); }, 'to throw');

        done();
    });

    it('it should implement boolean AND correctly', function (done) {
        var andQuery = query.and({
                type: 'Html'
            },
            {
                isInline: false
            });

        expect(andQuery, 'to be a function');

        expect([
            {
                type: 'Html',
                isInline: false
            },
            {
                type: 'Html',
                isInline: false,
                foo: 'bar'
            },
            {
                type: 'Html',
                isInline: false,
                inline: function () { return 'foo'; }
            },
            {
                type: 'Html',
                isInline: false,
                matcher: /^http:/
            },
            {
                type: 'Html',
                isInline: false,
                amount: 10
            }
        ], 'to be an array whose items satisfy', function (item) {
            expect(andQuery(item), 'to be true');
        });

        expect([
            {
                type: 'JavaScript',
                isInline: false
            },
            {
                type: 'Css',
                isInline: false,
                foo: 'bar'
            },
            {
                type: 'HtmlTemplate',
                isInline: false,
                inline: function () { return 'foo'; }
            },
            {
                type: 'Html',
                isInline: true,
                matcher: /^http:/
            },
            {
                type: 'Xml',
                isInline: true,
                amount: 10
            }
        ], 'to be an array whose items satisfy', function (item) {
            expect(andQuery(item), 'to be false');
        });

        done();
    });

    it('it should implement boolean OR correctly', function (done) {
        var orQuery = query.or({
                type: 'Html'
            },
            {
                isInline: false
            });

        expect(orQuery, 'to be a function');

        expect([
            {
                type: 'Html',
                isInline: true
            },
            {
                type: 'Html',
                isInline: false
            },
            {
                type: 'Html'
            },
            {
                isInline: false
            },
            {
                type: 'Html',
                isInline: true,
                amount: 10
            }
        ], 'to be an array whose items satisfy', function (item) {
            expect(orQuery(item), 'to be true');
        });

        expect([
            {},
            {
                type: 'JavaScript',
                isInline: true
            },
            {
                type: 'Css',
                foo: 'bar'
            },
            {
                type: 'HtmlTemplate',
                inline: function () { return 'foo'; }
            },
            {
                isInline: true,
                matcher: /^http:/
            },
            {
                type: 'Xml',
                isInline: true,
                amount: 10
            }
        ], 'to be an array whose items satisfy', function (item) {
            expect(orQuery(item), 'to be false');
        });

        done();
    });

    it('it should implement boolean NOT correctly', function (done) {
        var notQuery = query.not({
                type: 'Html'
            });

        expect(notQuery, 'to be a function');

        expect([
            {},
            {
                type: 'JavaScript',
                isInline: true
            },
            {
                type: 'Css',
                foo: 'bar'
            },
            {
                type: 'HtmlTemplate',
                inline: function () { return 'foo'; }
            },
            {
                isInline: true,
                matcher: /^http:/
            },
            {
                type: 'Xml',
                isInline: true,
                amount: 10
            }
        ], 'to be an array whose items satisfy', function (item) {
            expect(notQuery(item), 'to be true');
        });

        expect([
            {
                type: 'Html',
                isInline: true
            },
            {
                type: 'Html',
                isInline: false
            },
            {
                type: 'Html'
            },
            {
                type: 'Html',
                isRepetitive: true
            },
            {
                type: 'Html',
                isInline: true,
                amount: 10
            }
        ], 'to be an array whose items satisfy', function (item) {
            expect(notQuery(item), 'to be false');
        });

        done();
    });
});

@@ -142,27 +142,24 @@
 ) %7B%0A    it('
-it 
 should throw
@@ -191,32 +191,32 @@
 nction (done) %7B%0A
+
         expect(f
@@ -574,35 +574,32 @@
    %7D);%0A%0A    it('
-it 
 should implement
@@ -2360,35 +2360,32 @@
    %7D);%0A%0A    it('
-it 
 should implement
@@ -3888,11 +3888,8 @@
 it('
-it 
 shou
@@ -5273,32 +5273,32 @@
 nction (item) %7B%0A
-
             expe
@@ -5337,32 +5337,877 @@
 );%0A        %7D);%0A%0A
+        done();%0A    %7D);%0A%0A    it('should implement string prefix matching', function (done) %7B%0A        var prefixMatcher = query.createPrefixMatcher('http');%0A%0A        expect(prefixMatcher, 'to be a function');%0A%0A        expect(%5B%0A            'http://fisk.dk',%0A            'http://cnn.com',%0A            'http://asetgraph.org',%0A            'https://github.com',%0A            'https://twitter.com'%0A        %5D, 'to be an array whose items satisfy', function (item) %7B%0A            expect(prefixMatcher(item), 'to be true');%0A        %7D);%0A%0A        expect(%5B%0A            ' http://fisk.dk',%0A            'htp://cnn.com',%0A            'ftp+http://asetgraph.org',%0A            'ftp://github.com',%0A            'gopher://twitter.com'%0A        %5D, 'to be an array whose items satisfy', function (item) %7B%0A            expect(prefixMatcher(item), 'to be false');%0A        %7D);%0A%0A
         done();%0A

Add tests for query prefixMatchers