Parcourir la source

Check image extract is valid

rigwild il y a 5 ans
Parent
commit
106bf31c01
1 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 7 0
      test/api/getImageExtracts.js

+ 7 - 0
test/api/getImageExtracts.js

@@ -2,6 +2,7 @@
 
 import test from 'ava'
 import request from 'supertest'
+import sharp from 'sharp'
 import fs from 'fs-extra'
 import path from 'path'
 import { apiPrefix, imageServedUrl, imagesPath } from '../../config'
@@ -99,4 +100,10 @@ test.serial('Extracts were successfully generated', async t => {
 
   // Check `bathroom/extracts/x5_y2/zone00001/bathroom_zone00001_10.png`
   t.true(await fs.pathExists(aBathroomConfigZoneImg))
+
+  // Check image's type, width and height
+  const metadata = await sharp(aBathroomConfigZoneImg).metadata()
+  t.is(metadata.width, 160, json(metadata))
+  t.is(metadata.height, 400, json(metadata))
+  t.is(metadata.format, 'png', json(metadata))
 })