recital / core / test / scenes.spec.js
scenes.spec.js
Raw
const assert = require('assert')
const fs = require('fs')
const path = require('path')

const parseFlat = require('../dist/stage-parser').parseFlat

const sceneDataPath = path.resolve(__dirname, './data/scenes/');
const sceneExpectedPath = path.resolve(__dirname, './expected/scenes/')

const files = fs.readdirSync(sceneDataPath);
for (let file of files) {

	it(`should parse ${file} correctly`, () => {
		const entryPath = path.resolve(sceneDataPath, file)
		const expectedPath = path.resolve(sceneExpectedPath, path.basename(file, '.stage') + '-flats.json')
		const str = fs.readFileSync(entryPath, 'utf-8')
		const json = JSON.parse(fs.readFileSync(expectedPath, 'utf-8'))
	
		const flats = parseFlat(str)
	
		assert.deepStrictEqual(flats, json)
	})
	
}