9eb69a0593
Feature: Issue 3645 Change-Id: I5b38ce872295c5d39790d3768ca581f07c050785
127 lines
3.5 KiB
HTML
127 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<!--
|
|
Copyright (C) 2015 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-file-list</title>
|
|
|
|
<script src="../../bower_components/webcomponentsjs/webcomponents.min.js"></script>
|
|
<script src="../../bower_components/web-component-tester/browser.js"></script>
|
|
<script src="../../bower_components/page/page.js"></script>
|
|
<script src="../scripts/changes.js"></script>
|
|
<script src="../scripts/fake-app.js"></script>
|
|
<script src="../scripts/util.js"></script>
|
|
|
|
<link rel="import" href="../../bower_components/iron-test-helpers/iron-test-helpers.html">
|
|
<link rel="import" href="../elements/gr-file-list.html">
|
|
|
|
<test-fixture id="basic">
|
|
<template>
|
|
<gr-file-list></gr-file-list>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<script>
|
|
suite('gr-file-list tests', function() {
|
|
var element;
|
|
var server;
|
|
|
|
setup(function() {
|
|
element = fixture('basic');
|
|
server = sinon.fakeServer.create();
|
|
server.respondWith(
|
|
'GET',
|
|
'/changes/42/revisions/1/files',
|
|
[
|
|
200,
|
|
{ 'Content-Type': 'application/json' },
|
|
')]}\'\n' +
|
|
JSON.stringify({
|
|
'/COMMIT_MSG': {
|
|
status: 'A',
|
|
lines_inserted: 9,
|
|
size_delta: 317,
|
|
size: 317
|
|
},
|
|
'myfile.txt': {
|
|
lines_inserted: 35,
|
|
size_delta: 1146,
|
|
size: 1167
|
|
}
|
|
}),
|
|
]
|
|
);
|
|
server.respondWith(
|
|
'GET',
|
|
'/changes/42/revisions/2/files',
|
|
[
|
|
200,
|
|
{ 'Content-Type': 'application/json' },
|
|
')]}\'\n' +
|
|
JSON.stringify({
|
|
'/COMMIT_MSG': {
|
|
status: 'A',
|
|
lines_inserted: 9,
|
|
size_delta: 317,
|
|
size: 317
|
|
},
|
|
'myfile.txt': {
|
|
lines_inserted: 35,
|
|
size_delta: 1146,
|
|
size: 1167
|
|
},
|
|
'file_added_in_rev2.txt': {
|
|
lines_inserted: 98,
|
|
size_delta: 234,
|
|
size: 136
|
|
}
|
|
}),
|
|
]
|
|
);
|
|
});
|
|
|
|
teardown(function() {
|
|
server.restore();
|
|
});
|
|
|
|
test('requests', function(done) {
|
|
element.changeNum = '42';
|
|
element.patchNum = '1';
|
|
element.reload();
|
|
server.respond();
|
|
|
|
element.async(function() {
|
|
var filenames = element.files.map(function(f) {
|
|
return f.__path;
|
|
});
|
|
assert.deepEqual(filenames, ['/COMMIT_MSG', 'myfile.txt']);
|
|
|
|
element.patchNum = '2';
|
|
element.reload();
|
|
server.respond();
|
|
element.async(function() {
|
|
filenames = element.files.map(function(f) {
|
|
return f.__path;
|
|
});
|
|
assert.deepEqual(filenames,
|
|
['/COMMIT_MSG', 'file_added_in_rev2.txt', 'myfile.txt']);
|
|
done();
|
|
}, 1);
|
|
}, 1)
|
|
});
|
|
});
|
|
</script>
|