<!DOCTYPE html>
<!--
@license
Copyright (C) 2016 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>gr-account-label</title>
<script src="/test/common-test-setup.js"></script>
<script src="/bower_components/webcomponentsjs/custom-elements-es5-adapter.js"></script>

<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<script src="/bower_components/web-component-tester/browser.js"></script>
<link rel="import" href="../../../test/common-test-setup.html"/>
<script src="../../../scripts/util.js"></script>

<link rel="import" href="gr-account-label.html">

<script>void(0);</script>

<test-fixture id="basic">
  <template>
    <gr-account-label></gr-account-label>
  </template>
</test-fixture>

<script>
  suite('gr-account-label tests', () => {
    let element;

    setup(() => {
      stub('gr-rest-api-interface', {
        getConfig() { return Promise.resolve({}); },
        getLoggedIn() { return Promise.resolve(false); },
      });
      element = fixture('basic');
      element._config = {
        user: {
          anonymous_coward_name: 'Anonymous Coward',
        },
      };
    });

    test('null guard', () => {
      assert.doesNotThrow(() => {
        element.account = null;
      });
    });

    test('missing email', () => {
      assert.equal('', element._computeEmailStr({name: 'foo'}));
    });

    test('computed fields', () => {
      assert.equal(
          element._computeAccountTitle({
            name: 'Andrew Bonventre',
            email: 'andybons+gerrit@gmail.com',
          }, /* additionalText= */ ''),
          'Andrew Bonventre <andybons+gerrit@gmail.com>');

      assert.equal(
          element._computeAccountTitle({
            name: 'Andrew Bonventre',
          }, /* additionalText= */ ''),
          'Andrew Bonventre');

      assert.equal(
          element._computeAccountTitle({
            email: 'andybons+gerrit@gmail.com',
          }, /* additionalText= */ ''),
          'Anonymous <andybons+gerrit@gmail.com>');

      assert.equal(element._computeShowEmailClass(
          {
            name: 'Andrew Bonventre',
            email: 'andybons+gerrit@gmail.com',
          }, /* additionalText= */ ''), '');

      assert.equal(element._computeShowEmailClass(
          {
            email: 'andybons+gerrit@gmail.com',
          }, /* additionalText= */ ''), 'showEmail');

      assert.equal(element._computeShowEmailClass(
          {name: 'Andrew Bonventre'},
          /* additionalText= */ ''
      ),
      '');

      assert.equal(element._computeShowEmailClass(undefined), '');

      assert.equal(
          element._computeEmailStr({name: 'test', email: 'test'}), '(test)');
      assert.equal(element._computeEmailStr({email: 'test'}, ''), 'test');
    });

    suite('_computeName', () => {
      test('not showing anonymous', () => {
        const account = {name: 'Wyatt'};
        assert.deepEqual(element._computeName(account, null), 'Wyatt');
      });

      test('showing anonymous but no config', () => {
        const account = {};
        assert.deepEqual(element._computeName(account, null),
            'Anonymous');
      });

      test('test for Anonymous Coward user and replace with Anonymous', () => {
        const config = {
          user: {
            anonymous_coward_name: 'Anonymous Coward',
          },
        };
        const account = {};
        assert.deepEqual(element._computeName(account, config),
            'Anonymous');
      });

      test('test for anonymous_coward_name', () => {
        const config = {
          user: {
            anonymous_coward_name: 'TestAnon',
          },
        };
        const account = {};
        assert.deepEqual(element._computeName(account, config),
            'TestAnon');
      });
    });

    suite('status in tooltip', () => {
      setup(() => {
        element = fixture('basic');
        element.account = {
          name: 'test',
          email: 'test@google.com',
          status: 'OOO until Aug 10th',
        };
        element._config = {
          user: {
            anonymous_coward_name: 'Anonymous Coward',
          },
        };
      });

      test('tooltip should contain status text', () => {
        assert.deepEqual(element.title,
            'test <test@google.com> (OOO until Aug 10th)');
      });

      test('status text should not have tooltip', () => {
        flushAsynchronousOperations();
        assert.deepEqual(element.$$('gr-limited-text').title, '');
      });

      test('status text should honor the name length and total length', () => {
        assert.deepEqual(
            element._computeStatusTextLength(element.account, element._config),
            31
        );
        assert.deepEqual(
            element._computeStatusTextLength({
              name: 'a very long long long long name',
            }, element._config),
            10
        );
      });
    });
  });
</script>
