Last active
September 9, 2019 17:58
-
-
Save ottomata/86ccdefe059de5a8bcf0f44c5e9e50c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateSchemaTests(title, majorVersion, schemaInfos) { | |
it(`All ${title} schemas should have title ${title} `, function() { | |
schemaInfos.forEach((info) => { | |
assert.equal(info.schema.title, title); | |
}); | |
}); | |
it(`All ${title} major version ${majorVersion} schemas should be ${majorVersion}.x.y`, function() { | |
schemaInfos.forEach((info) => { | |
assert.equal(semver.coerce(_.get(info.schema, '$id')).major, majorVersion); | |
}); | |
}); | |
// ... other tests and assertions here | |
// E.g. it('backwards compatible, etc.') | |
} | |
describe('Test Schema Conventions', function() { | |
let fixture; | |
before('Copying fixtures to temp directory and declaring tests', async function() { | |
// Copy the fixtures/ dir into a temp directory that is automatically | |
// cleaned up after each test. | |
fixture = testFixture(); | |
await fixture.copy(); | |
const schemaBasePath = fixture.resolve('schemas/'); | |
const schemasByTitleAndMajor = await findSchemasByTitleAndMajor(schemaBasePath); | |
describe('Each schema should conform', function() { | |
_.keys(schemasByTitleAndMajor).forEach((title) => { | |
_.keys(schemasByTitleAndMajor[title]).forEach((majorVersion) => { | |
generateSchemaTests( | |
title, | |
majorVersion, | |
schemasByTitleAndMajor[title][majorVersion] | |
); | |
}); | |
}); | |
}); | |
}); | |
it.skip('This is a required placeholder to allow before() to work', function () { }); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test Schema Conventions | |
- This is a required placeholder to allow before() to work | |
Each schema should conform | |
✓ All basic schemas should have title basic | |
✓ All basic major version 1 schemas should be 1.x.y | |
✓ All common schemas should have title common | |
✓ All common major version 1 schemas should be 1.x.y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment