Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Refactor test command integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
notlee committed Jun 14, 2021
1 parent d3d4738 commit b76a385
Showing 1 changed file with 98 additions and 91 deletions.
189 changes: 98 additions & 91 deletions test/integration/test/test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,108 +26,115 @@ describe('obt test', function () {
await rimraf(testDirectory);
});

describe('given a valid component', function () {

beforeEach(async function () {
const name = 'o-test-component';
const tag = 'v2.2.9';
await execa('git', ['clone', '--depth', 1, '--branch', tag, `https://github.com/Financial-Times/${name}.git`, './']);
await execa(obt, ['install']);
});

it('passes', async function () {
try {
await execa(obt, ['test']);
} catch (error) {
throw new Error(`Test command failed: ${error}`);
}
});
});

describe('given a component with no primary Sass mixin', function () {

beforeEach(async function () {
const name = 'o-test-component';
const tag = 'v2.2.17';
await execa('git', ['clone', '--depth', 1, '--branch', tag, `https://github.com/Financial-Times/${name}.git`, './']);
await execa(obt, ['install']);
describe('given a component', function () {

describe('that is valid', function () {

beforeEach(async function () {
const name = 'o-test-component';
const tag = 'v2.2.9';
await execa('git', ['clone', '--depth', 1, '--branch', tag, `https://github.com/Financial-Times/${name}.git`, './']);
await execa(obt, ['install']);
});

it('passes', async function () {
try {
await execa(obt, ['test']);
} catch (error) {
throw new Error(`Test command failed: ${error}`);
}
});
});

it('fails', async function () {
try {
await execa(obt, ['test']);
throw new Error('The test command did not throw an error as expected.');
} catch (error) {
proclaim.include(
error.stdout,
'primary mixin',
'Failed but with an unexpected error message: ' + error.stdout
);
}
describe('with no primary Sass mixin', function () {

beforeEach(async function () {
const name = 'o-test-component';
const tag = 'v2.2.17';
await execa('git', ['clone', '--depth', 1, '--branch', tag, `https://github.com/Financial-Times/${name}.git`, './']);
await execa(obt, ['install']);
});

it('fails', async function () {
try {
await execa(obt, ['test']);
throw new Error('The test command did not throw an error as expected.');
} catch (error) {
proclaim.include(
error.stdout,
'primary mixin',
'Failed but with an unexpected error message: ' + error.stdout
);
}
});
});
});

describe('given a library with no primary Sass mixin', function () {

beforeEach(async function () {
const name = 'o-test-component';
const tag = 'v2.2.20';
await execa('git', ['clone', '--depth', 1, '--branch', tag, `https://github.com/Financial-Times/${name}.git`, './']);
await execa(obt, ['install']);
describe('which outputs CSS by default on @import', function () {

beforeEach(async function () {
const name = 'o-test-component';
const tag = 'v2.2.18';
await execa('git', ['clone', '--depth', 1, '--branch', tag, `https://github.com/Financial-Times/${name}.git`, './']);
await execa(obt, ['install']);
});

it('fails', async function () {
try {
await execa(obt, ['test']);
throw new Error('The test command did not throw an error as expected.');
} catch (error) {
proclaim.include(
error.stdout,
'CSS was output by default',
'Failed but with an unexpected error message: ' + error.stdout
);
}
});
});

it('passes', async function () {
try {
await execa(obt, ['test']);
} catch (error) {
throw new Error(`Test command failed: ${error}`);
}
});
});

describe('given a component which outputs CSS by default on @import', function () {

beforeEach(async function () {
const name = 'o-test-component';
const tag = 'v2.2.18';
await execa('git', ['clone', '--depth', 1, '--branch', tag, `https://github.com/Financial-Times/${name}.git`, './']);
await execa(obt, ['install']);
describe('given a library', function () {
describe('with no primary Sass mixin', function () {

beforeEach(async function () {
const name = 'o-test-component';
const tag = 'v2.2.20';
await execa('git', ['clone', '--depth', 1, '--branch', tag, `https://github.com/Financial-Times/${name}.git`, './']);
await execa(obt, ['install']);
});

it('passes', async function () {
try {
await execa(obt, ['test']);
} catch (error) {
throw new Error(`Test command failed: ${error}`);
}
});
});

it('fails', async function () {
try {
await execa(obt, ['test']);
throw new Error('The test command did not throw an error as expected.');
} catch (error) {
proclaim.include(
error.stdout,
'CSS was output by default',
'Failed but with an unexpected error message: ' + error.stdout
);
}
describe('which outputs CSS by default on @import', function () {

beforeEach(async function () {
const name = 'o-test-component';
const tag = 'v2.2.21';
await execa('git', ['clone', '--depth', 1, '--branch', tag, `https://github.com/Financial-Times/${name}.git`, './']);
await execa(obt, ['install']);
});

it('fails', async function () {
try {
await execa(obt, ['test']);
throw new Error('The test command did not throw an error as expected.');
} catch (error) {
proclaim.include(
error.stdout,
'CSS was output by default',
'Failed but with an unexpected error message: ' + error.stdout
);
}
});
});
});

describe('given a library which outputs CSS by default on @import', function () {

beforeEach(async function () {
const name = 'o-test-component';
const tag = 'v2.2.21';
await execa('git', ['clone', '--depth', 1, '--branch', tag, `https://github.com/Financial-Times/${name}.git`, './']);
await execa(obt, ['install']);
});

it('fails', async function () {
try {
await execa(obt, ['test']);
throw new Error('The test command did not throw an error as expected.');
} catch (error) {
proclaim.include(
error.stdout,
'CSS was output by default',
'Failed but with an unexpected error message: ' + error.stdout
);
}
});
});
});

0 comments on commit b76a385

Please sign in to comment.