| <!DOCTYPE html> |
| <!-- |
| Copyright (C) 2017 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-group-audit-log</title> |
| |
| <script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> |
| <script src="../../../bower_components/web-component-tester/browser.js"></script> |
| <link rel="import" href="../../../test/common-test-setup.html"/> |
| <link rel="import" href="gr-group-audit-log.html"> |
| |
| <script>void(0);</script> |
| |
| <test-fixture id="basic"> |
| <template> |
| <gr-group-audit-log></gr-group-audit-log> |
| </template> |
| </test-fixture> |
| |
| <script> |
| suite('gr-group-audit-log tests', () => { |
| let element; |
| let sandbox; |
| |
| setup(() => { |
| sandbox = sinon.sandbox.create(); |
| element = fixture('basic'); |
| }); |
| |
| teardown(() => { |
| sandbox.restore(); |
| }); |
| |
| suite('members', () => { |
| test('test getNameForMember', () => { |
| let account = { |
| member: { |
| username: 'test-user', |
| _account_id: 12, |
| }, |
| }; |
| assert.equal(element._getNameForMember(account.member, false), |
| 'test-user'); |
| |
| account = { |
| member: { |
| name: 'test-name', |
| _account_id: 12, |
| }, |
| }; |
| assert.equal(element._getNameForMember(account.member), 'test-name'); |
| |
| account = { |
| user: { |
| email: 'test-email@gmail.com', |
| }, |
| }; |
| assert.equal(element._getNameForMember(account.user), 'test-email'); |
| }); |
| }); |
| |
| suite('users', () => { |
| test('test _getName', () => { |
| let account = { |
| user: { |
| username: 'test-user', |
| _account_id: 12, |
| }, |
| }; |
| assert.equal(element._getNameForUser(account.user), 'test-user (12)'); |
| |
| account = { |
| user: { |
| name: 'test-name', |
| _account_id: 12, |
| }, |
| }; |
| assert.equal(element._getNameForUser(account.user), 'test-name (12)'); |
| |
| account = { |
| user: { |
| email: 'test-email@gmail.com', |
| _account_id: 12, |
| }, |
| }; |
| assert.equal(element._getNameForUser(account.user), 'test-email (12)'); |
| }); |
| |
| test('test _account_id not present', () => { |
| let account = { |
| user: { |
| username: 'test-user', |
| }, |
| }; |
| assert.equal(element._getNameForUser(account.user), 'test-user'); |
| |
| account = { |
| user: { |
| name: 'test-name', |
| }, |
| }; |
| assert.equal(element._getNameForUser(account.user), 'test-name'); |
| |
| account = { |
| user: { |
| email: 'test-email@gmail.com', |
| }, |
| }; |
| assert.equal(element._getNameForUser(account.user), 'test-email'); |
| }); |
| }); |
| |
| suite('404', () => { |
| test('fires page-error', done => { |
| element.groupId = 1; |
| |
| const response = {status: 404}; |
| sandbox.stub( |
| element.$.restAPI, 'getGroupAuditLog', (group, errFn) => { |
| errFn(response); |
| }); |
| |
| element.addEventListener('page-error', e => { |
| assert.deepEqual(e.detail.response, response); |
| done(); |
| }); |
| |
| element._getAuditLogs(); |
| }); |
| }); |
| }); |
| </script> |