import { conditional, raw } from 'ember-awesome-macros';
import { module, test } from 'qunit';
import compute from '../helpers/compute';

module('Integration | Macro | conditional');

test('returns undefined when doesn\'t exist', function(assert) {
  compute({
    assert,
    computed: conditional('condition', 'expr1', 'expr2'),
    strictEqual: undefined
  });
});

test('returns first value when true', function(assert) {
  compute({
    assert,
    computed: conditional('condition', 'expr1', 'expr2'),
    properties: {
      condition: true,
      expr1: 'val 1',
      expr2: 'val 2'
    },
    strictEqual: 'val 1'
  });
});

test('returns second value when false', function(assert) {
  compute({
    assert,
    computed: conditional('condition', 'expr1', 'expr2'),
    properties: {
      condition: false,
      expr1: 'val 1',
      expr2: 'val 2'
    },
    strictEqual: 'val 2'
  });
});

test('composable: returns first value when true', function(assert) {
  compute({
    assert,
    computed: conditional(true, raw('val 1'), raw('val 2')),
    strictEqual: 'val 1'
  });
});

@@ -893,24 +893,511 @@
 %0A  %7D);%0A%7D);%0A%0A
+test('doesn%5C't break when missing third param', function(assert) %7B%0A  compute(%7B%0A    assert,%0A    computed: conditional('condition', 'expr1'),%0A    properties: %7B%0A      condition: true,%0A      expr1: 'val 1'%0A    %7D,%0A    strictEqual: 'val 1'%0A  %7D);%0A%7D);%0A%0Atest('allows third param implicit false', function(assert) %7B%0A  compute(%7B%0A    assert,%0A    computed: conditional('condition', 'expr1'),%0A    properties: %7B%0A      condition: false,%0A      expr1: 'val 1'%0A    %7D,%0A    strictEqual: undefined%0A  %7D);%0A%7D);%0A%0A
 test('compos

add a conditional test for leaving off the last param