From 9ea7dcd46e9d2f70a155a41e1262a3379dd48228 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Sun, 14 Nov 2021 22:24:26 +0700 Subject: [PATCH] add test for xmeml #839 --- src/__snapshots__/edlFormats.test.js.snap | 30 + src/edlFormats.test.js | 10 +- src/fixtures/Final Cut Pro XMEML.xml | 1511 +++++++++++++++++++++ 3 files changed, 1549 insertions(+), 2 deletions(-) create mode 100644 src/__snapshots__/edlFormats.test.js.snap create mode 100644 src/fixtures/Final Cut Pro XMEML.xml diff --git a/src/__snapshots__/edlFormats.test.js.snap b/src/__snapshots__/edlFormats.test.js.snap new file mode 100644 index 00000000..ffde466e --- /dev/null +++ b/src/__snapshots__/edlFormats.test.js.snap @@ -0,0 +1,30 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`parses xmeml 1 1`] = ` +Array [ + Object { + "end": 8.56, + "start": 0, + }, + Object { + "end": 13.12, + "start": 8.56, + }, + Object { + "end": 19.12, + "start": 13.12, + }, + Object { + "end": 27.96, + "start": 19.12, + }, + Object { + "end": 39.08, + "start": 27.96, + }, + Object { + "end": 49.36, + "start": 39.08, + }, +] +`; diff --git a/src/edlFormats.test.js b/src/edlFormats.test.js index 6b6f0920..bf851e7f 100644 --- a/src/edlFormats.test.js +++ b/src/edlFormats.test.js @@ -1,7 +1,9 @@ import fs from 'fs'; import { join } from 'path'; -import { parseYouTube, formatYouTube, parseMplayerEdl } from './edlFormats'; +import { parseYouTube, formatYouTube, parseMplayerEdl, parseXmeml } from './edlFormats'; + +const readFixture = async (name, encoding = 'utf-8') => fs.promises.readFile(join(__dirname, 'fixtures', name), encoding); it('parseYoutube', () => { const str = ` @@ -83,7 +85,7 @@ it('parseMplayerEdl', async () => { `; */ - const str = await fs.promises.readFile(join(__dirname, 'fixtures', 'mplayer.edl'), 'utf-8'); + const str = await readFixture('mplayer.edl'); expect(await parseMplayerEdl(str)).toEqual([ { start: 0, @@ -129,3 +131,7 @@ it('parseMplayerEdl, starting at 0', async () => { }, }]); }); + +it('parses xmeml 1', async () => { + expect(await parseXmeml(await readFixture('Final Cut Pro XMEML.xml'))).toMatchSnapshot(); +}); diff --git a/src/fixtures/Final Cut Pro XMEML.xml b/src/fixtures/Final Cut Pro XMEML.xml new file mode 100644 index 00000000..41b4123a --- /dev/null +++ b/src/fixtures/Final Cut Pro XMEML.xml @@ -0,0 +1,1511 @@ + + + + Untitled Project 1 + + + add + Media Bins + + + + add + DuaLipa.mp4 + 5615 + + FALSE + 25 + + -1 + -1 + DuaLipa.mp4 + TRUE + + + + + FALSE + + + + + + + + + + + + + + + + + add + Sequence 1 + 1234 + + FALSE + 25 + + + + FALSE + 25 + + 90016 + source + NDF + + -1 + -1 + + + + + + + + \ No newline at end of file