1
- const { Darknet, DarknetExperimental } = require ( '../darknet' ) ;
1
+ const { Darknet } = require ( '../darknet' ) ;
2
2
const path = require ( 'path' ) ;
3
3
4
4
const config = {
@@ -90,48 +90,51 @@ describe('darknet', () => {
90
90
91
91
it ( 'detects various images' , ( ) => {
92
92
darknet = new Darknet ( config ) ;
93
+
93
94
const dog = darknet . detect ( image ( 'dog.jpg' ) ) ;
94
- expect ( JSON . stringify ( dog ) ) . toBe ( JSON . stringify ( DOG_RESULT ) ) ;
95
+ expect ( dog ) . toEqual ( DOG_RESULT ) ;
96
+
95
97
const eagle = darknet . detect ( image ( 'eagle.jpg' ) ) ;
96
- expect ( JSON . stringify ( eagle ) ) . toBe ( JSON . stringify ( EAGLE_RESULT ) ) ;
98
+ expect ( eagle ) . toEqual ( EAGLE_RESULT ) ;
99
+
97
100
const giraffe = darknet . detect ( image ( 'giraffe.jpg' ) ) ;
98
- expect ( JSON . stringify ( giraffe ) ) . toBe ( JSON . stringify ( GIRAFFE_RESULT ) ) ;
101
+ expect ( giraffe ) . toEqual ( GIRAFFE_RESULT ) ;
99
102
} ) ;
100
103
101
- it ( 'detects various images async (concurrent)' , async ( ) => {
102
- darknet_a = new Darknet ( config ) ;
103
- darknet_b = new Darknet ( config ) ;
104
- darknet_c = new Darknet ( config ) ;
105
-
106
- return Promise . all ( [
107
- darknet_a . detectAsync ( image ( 'dog.jpg' ) ) ,
108
- darknet_b . detectAsync ( image ( 'eagle.jpg' ) ) ,
109
- darknet_c . detectAsync ( image ( 'giraffe.jpg' ) )
110
- ] ) . then ( values => {
111
- expect ( JSON . stringify ( values [ 0 ] ) ) . toBe ( JSON . stringify ( DOG_RESULT ) ) ;
112
- expect ( JSON . stringify ( values [ 1 ] ) ) . toBe ( JSON . stringify ( EAGLE_RESULT ) ) ;
113
- expect ( JSON . stringify ( values [ 2 ] ) ) . toBe ( JSON . stringify ( GIRAFFE_RESULT ) ) ;
114
- } ) ;
115
- } ) ;
104
+ // xit('detects various images async (concurrent)', async () => {
105
+ // darknet_a = new Darknet(config);
106
+ // darknet_b = new Darknet(config);
107
+ // darknet_c = new Darknet(config);
108
+
109
+ // return Promise.all([
110
+ // darknet_a.detectAsync(image('dog.jpg')),
111
+ // darknet_b.detectAsync(image('eagle.jpg')),
112
+ // darknet_c.detectAsync(image('giraffe.jpg'))
113
+ // ]).then(values => {
114
+ // expect(JSON.stringify(values[0])).toBe(JSON.stringify(DOG_RESULT));
115
+ // expect(JSON.stringify(values[1])).toBe(JSON.stringify(EAGLE_RESULT));
116
+ // expect(JSON.stringify(values[2])).toBe(JSON.stringify(GIRAFFE_RESULT));
117
+ // });
118
+ // });
119
+
120
+ // describe('experimental', () => {
121
+ // xit('detects images async', async () => {
122
+ // darknet = new DarknetExperimental(config);
123
+ // return Promise.all([
124
+ // darknet.detectAsync(image('dog.jpg')),
125
+ // darknet.detectAsync(image('eagle.jpg')),
126
+ // darknet.detectAsync(image('giraffe.jpg'))
127
+ // ]).then(values => {
128
+ // expect(JSON.stringify(values[0])).toBe(JSON.stringify(DOG_RESULT));
129
+ // expect(JSON.stringify(values[1])).toBe(JSON.stringify(EAGLE_RESULT));
130
+ // expect(JSON.stringify(values[2])).toBe(JSON.stringify(GIRAFFE_RESULT));
131
+ // });
132
+ // });
116
133
117
- describe ( 'experimental' , ( ) => {
118
- it ( 'detects images async' , async ( ) => {
119
- darknet = new DarknetExperimental ( config ) ;
120
- return Promise . all ( [
121
- darknet . detectAsync ( image ( 'dog.jpg' ) ) ,
122
- darknet . detectAsync ( image ( 'eagle.jpg' ) ) ,
123
- darknet . detectAsync ( image ( 'giraffe.jpg' ) )
124
- ] ) . then ( values => {
125
- expect ( JSON . stringify ( values [ 0 ] ) ) . toBe ( JSON . stringify ( DOG_RESULT ) ) ;
126
- expect ( JSON . stringify ( values [ 1 ] ) ) . toBe ( JSON . stringify ( EAGLE_RESULT ) ) ;
127
- expect ( JSON . stringify ( values [ 2 ] ) ) . toBe ( JSON . stringify ( GIRAFFE_RESULT ) ) ;
128
- } ) ;
129
- } ) ;
130
-
131
- } )
134
+ // })
132
135
133
136
} ) ;
134
137
135
138
function image ( location ) {
136
139
return path . resolve ( __dirname + '/../examples/' + location ) ;
137
- }
140
+ }
0 commit comments