"use strict";

var assert = require('assert');
var vows = require('vows');
var p = require('../src/server/predicates');

vows.describe('predicates')
  .addBatch({
    'checkLevel': {
      'an item without a level': {
        topic: function() {
          return {body: 'nothing'};
        },
        'settings with a critical minimumLevel': {
          topic: function(item) {
            var settings = {minimumLevel: 'critical'};
            return p.checkLevel(item, settings);
          },
          'should not send': function(topic) {
            assert.isFalse(topic);
          }
        }
      },
      'an item with an unknown level': {
        topic: function() {
          return {level: 'wooo'};
        },
        'settings with an error minimumLevel': {
          topic: function(item) {
            var settings = {minimumLevel: 'error'};
            return p.checkLevel(item, settings);
          },
          'should not send': function(topic) {
            assert.isFalse(topic);
          }
        },
        'settings with an unknown minimumLevel': {
          topic: function(item) {
            var settings = {minimumLevel: 'yesss'};
            return p.checkLevel(item, settings);
          },
          'should send': function(topic) {
            assert.isTrue(topic);
          }
        },
        'settings without a minimumLevel': {
          topic: function(item) {
            var settings = {nothing: 'to see here'};
            return p.checkLevel(item, settings);
          },
          'should send': function(topic) {
            assert.isTrue(topic);
          }
        }
      },
      'an item with a warning level': {
        topic: function() {
          return {level: 'warning'};
        },
        'settings with an error minimumLevel': {
          topic: function(item) {
            var settings = {minimumLevel: 'error'};
            return p.checkLevel(item, settings);
          },
          'should not send': function(topic) {
            assert.isFalse(topic);
          }
        },
        'settings with an info minimumLevel': {
          topic: function(item) {
            var settings = {minimumLevel: 'info'};
            return p.checkLevel(item, settings);
          },
          'should send': function(topic) {
            assert.isTrue(topic);
          }
        },
        'settings with a warning minimumLevel': {
          topic: function(item) {
            var settings = {minimumLevel: 'warning'};
            return p.checkLevel(item, settings);
          },
          'should send': function(topic) {
            assert.isTrue(topic);
          }
        }
      }
    }
  }).export(module, {error: false});

@@ -320,23 +320,22 @@
 ritical 
-minimum
+report
 Level': 
@@ -390,39 +390,38 @@
 var settings = %7B
-minimum
+report
 Level: 'critical
@@ -737,39 +737,38 @@
 s with an error 
-minimum
+report
 Level': %7B%0A      
@@ -815,39 +815,38 @@
 var settings = %7B
-minimum
+report
 Level: 'error'%7D;
@@ -1047,23 +1047,22 @@
 unknown 
-minimum
+report
 Level': 
@@ -1117,39 +1117,38 @@
 var settings = %7B
-minimum
+report
 Level: 'yesss'%7D;
@@ -1338,23 +1338,22 @@
 thout a 
-minimum
+report
 Level': 
@@ -1759,23 +1759,22 @@
 n error 
-minimum
+report
 Level': 
@@ -1829,39 +1829,38 @@
 var settings = %7B
-minimum
+report
 Level: 'error'%7D;
@@ -2058,23 +2058,22 @@
 an info 
-minimum
+report
 Level': 
@@ -2128,39 +2128,38 @@
 var settings = %7B
-minimum
+report
 Level: 'info'%7D;%0A
@@ -2353,23 +2353,22 @@
 warning 
-minimum
+report
 Level': 
@@ -2435,15 +2435,14 @@
  = %7B
-minimum
+report
 Leve

fix tests to reflect new option name