This repository was archived by the owner on Oct 27, 2019. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathtest.js
More file actions
116 lines (95 loc) · 2.46 KB
/
Copy pathtest.js
File metadata and controls
116 lines (95 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
var t = require('tap')
var placeIntoPS = require('./')
t.test("works like an old stream", function(t){
var config = {
uri: "http://graph.facebook.com/subtlegradient/picture",
name: "SubtleGradient"
}
var stream = placeIntoPS(config)
stream.on('data', function(data){
t.ok(data > 0)
})
stream.on('end', function(){
t.end()
})
})
t.test('exists', function(t){
t.ok(placeIntoPS)
t.is(typeof placeIntoPS, 'function')
t.end()
})
t.test('emits error with no config', function(t){
var stream = placeIntoPS()
stream.on('error', function(error){
t.pass(error)
t.end()
})
stream.read()
})
t.test('emits error with bad uri', function(t){
var stream = placeIntoPS({ })
stream.on('error', function(error){
t.pass(error)
t.end()
})
stream.read()
})
t.test('emits error with bad uri', function(t){
var stream = placeIntoPS({ uri:"http://localhost:9999/this-should-not-work" })
stream.on('error', function(error){
t.pass(error)
t.end()
})
stream.read()
})
t.test('place a url into a photoshop document', function(t) {
var config = {
uri: "http://graph.facebook.com/subtlegradient/picture"
}
var stream = placeIntoPS(config)
stream.on('data', function(data){
console.log(data)
})
stream.on('error', function(error){
console.error(error)
t.fail(error)
t.end()
})
stream.on('end', function(){
require('photoshop').invoke(function(){
return PSFakeDOM.getParsedMetaDataForLayerId(app.activeDocument.activeLayer.id)
}, function(error, parsedMetadata){
t.is(parsedMetadata.source, config.uri, "uri must be added to the layer metadata")
t.end()
})
})
})
t.test('implements streams2', function(t){
var config = {
uri: "http://graph.facebook.com/subtlegradient/picture",
name: "SubtleGradient"
}
var stream = placeIntoPS(config)
t.end()
})
t.test('place a url into a photoshop document with a name', function(t) {
var config = {
uri: "http://graph.facebook.com/subtlegradient/picture",
name: "SubtleGradient"
}
var stream = placeIntoPS(config)
stream.on('error', function(error){
console.error(error)
t.fail(error)
t.end()
})
stream.on('end', function(){
require('photoshop').invoke(function(){
return app.activeDocument.activeLayer.name
}, function(error, layerName){
t.is(layerName, config.name, "layerName must be applied to layer")
t.end()
})
})
stream.resume()
})