@@ -45,6 +45,32 @@ describe('tray module', () => {
4545 it ( 'is an instance of Tray' , ( ) => {
4646 expect ( tray ) . to . be . an . instanceOf ( Tray ) ;
4747 } ) ;
48+
49+ ifdescribe ( process . platform === 'darwin' ) ( 'with layered images' , ( ) => {
50+ afterEach ( ( ) => {
51+ if ( tray && ! tray . isDestroyed ( ) ) {
52+ tray . destroy ( ) ;
53+ }
54+ } ) ;
55+
56+ it ( 'accepts an object with layers array in constructor' , ( ) => {
57+ const templateImage = nativeImage . createFromPath ( path . join ( __dirname , 'fixtures' , 'assets' , 'logo_Template.png' ) ) ;
58+ const colorImage = nativeImage . createFromPath ( path . join ( __dirname , 'fixtures' , 'assets' , 'logo.png' ) ) ;
59+ expect ( ( ) => {
60+ tray = new Tray ( { layers : [ templateImage , colorImage ] } ) ;
61+ } ) . to . not . throw ( ) ;
62+ expect ( tray ) . to . be . an . instanceOf ( Tray ) ;
63+ } ) ;
64+
65+ it ( 'accepts layers from paths in constructor' , ( ) => {
66+ const templatePath = path . join ( __dirname , 'fixtures' , 'assets' , 'logo_Template.png' ) ;
67+ const colorPath = path . join ( __dirname , 'fixtures' , 'assets' , 'logo.png' ) ;
68+ expect ( ( ) => {
69+ tray = new Tray ( { layers : [ templatePath , colorPath ] } ) ;
70+ } ) . to . not . throw ( ) ;
71+ expect ( tray ) . to . be . an . instanceOf ( Tray ) ;
72+ } ) ;
73+ } ) ;
4874 } ) ;
4975
5076 ifdescribe ( process . platform === 'darwin' ) ( 'tray get/set ignoreDoubleClickEvents' , ( ) => {
@@ -148,6 +174,32 @@ describe('tray module', () => {
148174 it ( 'accepts empty image' , ( ) => {
149175 tray . setImage ( nativeImage . createEmpty ( ) ) ;
150176 } ) ;
177+
178+ ifdescribe ( process . platform === 'darwin' ) ( 'with layered images' , ( ) => {
179+ it ( 'accepts an object with layers array' , ( ) => {
180+ const templateImage = nativeImage . createFromPath ( path . join ( __dirname , 'fixtures' , 'assets' , 'logo_Template.png' ) ) ;
181+ const colorImage = nativeImage . createFromPath ( path . join ( __dirname , 'fixtures' , 'assets' , 'logo.png' ) ) ;
182+ expect ( ( ) => {
183+ tray . setImage ( { layers : [ templateImage , colorImage ] } ) ;
184+ } ) . to . not . throw ( ) ;
185+ } ) ;
186+
187+ it ( 'accepts layers from paths' , ( ) => {
188+ const templatePath = path . join ( __dirname , 'fixtures' , 'assets' , 'logo_Template.png' ) ;
189+ const colorPath = path . join ( __dirname , 'fixtures' , 'assets' , 'logo.png' ) ;
190+ expect ( ( ) => {
191+ tray . setImage ( { layers : [ templatePath , colorPath ] } ) ;
192+ } ) . to . not . throw ( ) ;
193+ } ) ;
194+
195+ it ( 'handles mixed NativeImage and path layers' , ( ) => {
196+ const templateImage = nativeImage . createFromPath ( path . join ( __dirname , 'fixtures' , 'assets' , 'logo_Template.png' ) ) ;
197+ const colorPath = path . join ( __dirname , 'fixtures' , 'assets' , 'logo.png' ) ;
198+ expect ( ( ) => {
199+ tray . setImage ( { layers : [ templateImage , colorPath ] } ) ;
200+ } ) . to . not . throw ( ) ;
201+ } ) ;
202+ } ) ;
151203 } ) ;
152204
153205 describe ( 'tray.setPressedImage(image)' , ( ) => {
@@ -161,6 +213,24 @@ describe('tray module', () => {
161213 it ( 'accepts empty image' , ( ) => {
162214 tray . setPressedImage ( nativeImage . createEmpty ( ) ) ;
163215 } ) ;
216+
217+ ifdescribe ( process . platform === 'darwin' ) ( 'with layered images' , ( ) => {
218+ it ( 'accepts an object with layers array' , ( ) => {
219+ const templateImage = nativeImage . createFromPath ( path . join ( __dirname , 'fixtures' , 'assets' , 'logo_Template.png' ) ) ;
220+ const colorImage = nativeImage . createFromPath ( path . join ( __dirname , 'fixtures' , 'assets' , 'logo.png' ) ) ;
221+ expect ( ( ) => {
222+ tray . setPressedImage ( { layers : [ templateImage , colorImage ] } ) ;
223+ } ) . to . not . throw ( ) ;
224+ } ) ;
225+
226+ it ( 'accepts layers from paths' , ( ) => {
227+ const templatePath = path . join ( __dirname , 'fixtures' , 'assets' , 'logo_Template.png' ) ;
228+ const colorPath = path . join ( __dirname , 'fixtures' , 'assets' , 'logo.png' ) ;
229+ expect ( ( ) => {
230+ tray . setPressedImage ( { layers : [ templatePath , colorPath ] } ) ;
231+ } ) . to . not . throw ( ) ;
232+ } ) ;
233+ } ) ;
164234 } ) ;
165235
166236 ifdescribe ( process . platform === 'win32' ) ( 'tray.displayBalloon(image)' , ( ) => {
0 commit comments