github.com/olivere/camlistore@v0.0.0-20140121221811-1b7ac2da0199/server/camlistored/ui/blob_item_container_test.html (about) 1 <!-- 2 Copyright 2013 The Camlistore Authors 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 --> 16 17 <!doctype html> 18 <html> 19 <head> 20 <script src="closure/goog/base.js"></script> 21 <script src="./deps.js"></script> 22 <script> 23 goog.require('goog.events'); 24 goog.require('goog.testing.net.XhrIo'); 25 26 goog.require('cam.ServerConnection'); 27 goog.require('cam.BlobItemContainer'); 28 </script> 29 <link rel="stylesheet" href="blob_item.css" type="text/css"> 30 <link rel="stylesheet" href="blob_item_container.css" type="text/css"> 31 </head> 32 <body> 33 <script> 34 // Mock response from: http://127.0.0.1:3179/my-search/camli/search/recent?thumbnails=100 35 var recentBlobResponse = { 36 "recent": [ 37 { 38 "blobref": "sha1-5660088af0aa0d4f2294088f41284002a1baaa29", 39 "modtime": "2012-12-23T19:53:32Z", 40 "owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4" 41 }, 42 { 43 "blobref": "sha1-3ced53f0a11115e98d6e40ca4558680f2768f23e", 44 "modtime": "2012-12-23T19:19:37Z", 45 "owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4" 46 }, 47 { 48 "blobref": "sha1-19236d4922116d03738f1c8c6d9f14debbab798b", 49 "modtime": "2012-12-23T19:19:37Z", 50 "owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4" 51 } 52 ], 53 "sha1-19236d4922116d03738f1c8c6d9f14debbab798b": { 54 "blobRef": "sha1-19236d4922116d03738f1c8c6d9f14debbab798b", 55 "camliType": "permanode", 56 "mimeType": "application/json; camliType=permanode", 57 "permanode": { 58 "attr": { 59 "camliRoot": [ 60 "dev-pics-root" 61 ], 62 "title": [ 63 "Publish root node for dev-pics-root" 64 ] 65 } 66 }, 67 "size": 562, 68 "thumbnailHeight": 100, 69 "thumbnailSrc": "node.png", 70 "thumbnailWidth": 100 71 }, 72 "sha1-3ced53f0a11115e98d6e40ca4558680f2768f23e": { 73 "blobRef": "sha1-3ced53f0a11115e98d6e40ca4558680f2768f23e", 74 "camliType": "permanode", 75 "mimeType": "application/json; camliType=permanode", 76 "permanode": { 77 "attr": { 78 "camliRoot": [ 79 "dev-blog-root" 80 ], 81 "title": [ 82 "Publish root node for dev-blog-root" 83 ] 84 } 85 }, 86 "size": 562, 87 "thumbnailHeight": 100, 88 "thumbnailSrc": "node.png", 89 "thumbnailWidth": 100 90 }, 91 "sha1-5660088af0aa0d4f2294088f41284002a1baaa29": { 92 "blobRef": "sha1-5660088af0aa0d4f2294088f41284002a1baaa29", 93 "camliType": "permanode", 94 "mimeType": "application/json; camliType=permanode", 95 "permanode": { 96 "attr": { 97 "camliContent": [ 98 "sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725" 99 ] 100 } 101 }, 102 "size": 556, 103 "thumbnailHeight": 100, 104 "thumbnailSrc": "thumbnail/sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725/leisure-suit-tony.gif?mw=100&mh=100", 105 "thumbnailWidth": 100 106 }, 107 "sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725": { 108 "blobRef": "sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725", 109 "camliType": "file", 110 "file": { 111 "size": 37741, 112 "fileName": "leisure-suit-tony.gif", 113 "mimeType": "image/gif" 114 }, 115 "mimeType": "application/json; camliType=file", 116 "size": 198 117 } 118 }; 119 120 var connection = new cam.ServerConnection( 121 { 122 'searchRoot': '/my/test/search' 123 }, 124 goog.testing.net.XhrIo.send 125 ); 126 127 var container = new cam.BlobItemContainer(connection); 128 container.render(document.body); 129 130 container.showRecent(); 131 132 var request = goog.testing.net.XhrIo.getSendInstances().pop(); 133 request.simulateResponse(200, JSON.stringify(recentBlobResponse)); 134 </script> 135 </body> 136 </html>