Skip to content

Commit

Permalink
Update test data for STJ validator
Browse files Browse the repository at this point in the history
  • Loading branch information
yaniv-golan committed Nov 1, 2024
1 parent 67b7899 commit 621f3bc
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 19 deletions.
6 changes: 4 additions & 2 deletions tests/javascript/data/invalid_confidence_scores.stj.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"stj": {
"version": "0.6.0",
"metadata": {
"transcriber": {
"name": "TestTranscriber",
Expand All @@ -12,7 +14,7 @@
"start": 0.0,
"end": 5.0,
"text": "Confidence test",
"confidence": 1.2, // Invalid confidence score
"confidence": 1.2,
"words": [
{
"start": 0.0,
Expand All @@ -31,4 +33,4 @@
]
}
}
}
14 changes: 10 additions & 4 deletions tests/javascript/data/invalid_language.stj.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
{
"stj": {
"version": "0.6.0",
"metadata": {
"transcriber": {
"name": "TestTranscriber",
"version": "1.0"
},
"created_at": "2023-10-21T12:00:00Z",
"languages": ["xx"], // Invalid language code
"languages": [
"xx"
],
"source": {
"languages": ["en"]
"languages": [
"en"
]
}
},
"transcript": {
Expand All @@ -16,9 +22,9 @@
"start": 0.0,
"end": 5.0,
"text": "Sample text.",
"language": "yy" // Invalid language code
"language": "yy"
}
]
}
}
}
6 changes: 4 additions & 2 deletions tests/javascript/data/invalid_speaker_id.stj.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"stj": {
"version": "0.6.0",
"metadata": {
"transcriber": {
"name": "TestTranscriber",
Expand All @@ -18,9 +20,9 @@
"start": 0.0,
"end": 3.0,
"text": "Hello, this is a test.",
"speaker_id": "Speaker2" // Invalid speaker_id
"speaker_id": "Speaker2"
}
]
}
}
}
5 changes: 3 additions & 2 deletions tests/javascript/data/invalid_word_timing_mode.stj.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"stj": {
"version": "0.6.0",
"metadata": {
"transcriber": {
"name": "TestTranscriber",
Expand All @@ -19,10 +21,9 @@
"end": 1.0,
"text": "Hello"
}
// Missing "world" in the words array
]
}
]
}
}
}
4 changes: 3 additions & 1 deletion tests/javascript/data/overlapping_segments.stj.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"stj": {
"version": "0.6.0",
"metadata": {
"transcriber": {
"name": "TestTranscriber",
Expand All @@ -21,4 +23,4 @@
]
}
}
}
8 changes: 5 additions & 3 deletions tests/javascript/data/word_outside_segment_timings.stj.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"stj": {
"version": "0.6.0",
"metadata": {
"transcriber": {
"name": "TestTranscriber",
Expand All @@ -14,18 +16,18 @@
"text": "Timing mismatch",
"words": [
{
"start": -1.0, // Before segment start
"start": -1.0,
"end": 1.0,
"text": "Timing"
},
{
"start": 1.0,
"end": 4.0, // After segment end
"end": 4.0,
"text": "mismatch"
}
]
}
]
}
}
}
6 changes: 4 additions & 2 deletions tests/javascript/data/words_overlap_or_out_of_order.stj.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"stj": {
"version": "0.6.0",
"metadata": {
"transcriber": {
"name": "TestTranscriber",
Expand All @@ -19,7 +21,7 @@
"text": "Overlap"
},
{
"start": 1.0, // Starts before the previous word ends
"start": 1.0,
"end": 2.0,
"text": "test"
}
Expand All @@ -28,4 +30,4 @@
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"stj": {
"version": "0.6.0",
"metadata": {
"transcriber": {
"name": "TestTranscriber",
Expand All @@ -17,7 +19,6 @@
"start": 1.0,
"end": 1.0,
"text": "Zero"
// Missing 'word_duration' set to 'zero' in 'additional_info'
},
{
"start": 1.0,
Expand All @@ -29,4 +30,4 @@
]
}
}
}
4 changes: 3 additions & 1 deletion tests/javascript/test_stj_validator.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.setTimeout(10000); // Increase timeout to 10 seconds

const { exec } = require('child_process');
const path = require('path');

Expand All @@ -20,7 +22,7 @@ function runValidatorTest(stjFileName, expectedErrorMessage, done) {
}

test('Valid STJ file passes validation', (done) => {
const stjFile = path.join(__dirname, '..', '..', 'examples', 'simple.stj.json');
const stjFile = path.join(__dirname, '..', '..', 'examples', 'latest', 'simple.stj.json');
exec(`node ${validator} ${stjFile} ${schemaFile}`, (error, stdout, stderr) => {
expect(error).toBeNull();
expect(stdout).toContain('All validation checks passed.');
Expand Down

0 comments on commit 621f3bc

Please sign in to comment.