Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function() {
startApp();
beforeEach(setProperties);
setupWebAudioStub();
afterEach(function(done) {
// TODO(DBSTUB)
// reset firebase
this.timeout(5000);
let firebase = this.container.lookup('service:firebase');
firebase.remove(done);
});
}
describe('multiple', () => {
beforeEach(function() {
this.hook1 = function hook1() {}
this.hook2 = function hook2() {}
supportCodeLibraryBuilder.reset('path/to/project', uuid())
supportCodeLibraryBuilder.methods.Before(this.hook1) // eslint-disable-line babel/new-cap
supportCodeLibraryBuilder.methods.Before(this.hook2) // eslint-disable-line babel/new-cap
this.options = supportCodeLibraryBuilder.finalize()
})
it('adds the scenario hook definitions in the order of definition', function() {
expect(this.options.beforeTestCaseHookDefinitions).to.have.lengthOf(2)
expect(this.options.beforeTestCaseHookDefinitions[0].code).to.eql(
this.hook1
)
expect(this.options.beforeTestCaseHookDefinitions[1].code).to.eql(
this.hook2
)
describe(".addRow(...keys)", () => {
let keyboard;
beforeEach("init keyboard", () => {
keyboard = new ReplyKeyboard();
});
it("Should add elements to a row and return the right number of rows via .extract() method", () => {
keyboard
.addRow(...firstLoad)
.addRow(...secondLoad);
assert.equal(keyboard.length, 2);
});
it("Should have a length property after .addRow(), which returns the amount of rows", () => {
assert.equal(keyboard.addRow(...thirdLoad).length, 1);
});
});
describe('speak', () => {
const speakSpy = spy();
beforeEach(() => {
global.window.speechSynthesis = {
speak: speakSpy,
};
global.window.SpeechSynthesisUtterance = function SpeechSynthesisUtterance() {};
});
afterEach(() => {
speakSpy.resetHistory();
});
it('should not speak if disabled', () => {
const speak = speakFn({ enable: false });
speak({});
expect(speakSpy.called).to.eql(false);
});
export function itValidatesTheProperty (ctx, throwErrors, ...warningMessages) {
let def, instance, propertyName
beforeEach(function () {
def = ctx.def
instance = ctx.instance
propertyName = ctx.propertyName
})
it('should validate prop-types for instance', function () {
expect(helpers.validatePropTypes).to.have.been.calledWith(instance)
})
it(`should validate the property "${ctx.propertyName}"`, function () {
expect(helpers.validateProperty).to.have.been.calledWith(instance, propertyName, def)
})
if (throwErrors) {
if (warningMessages.length > 0) {
it('should throw errors', function () {
describe('with a missing config file', () => {
let response;
beforeEach(() => stub(path, 'dirname').callsFake(() => process.cwd()));
afterEach(() => path.dirname.restore());
beforeEach(async() => {
response = await sendMessage({
cssFile: join(__dirname, 'fixtures', 'simple.css'),
config: join('fixtures', 'nofile'),
});
});
beforeEach(closeStderr);
it('does not contain a response', () => {
expect(response).to.eql('');
});
it('logs a useful message', () => {
expect(fs.readFileSync(testOutput, 'utf8'))
.to.match(/No PostCSS Config/i);
});
});
});
describe(Class.name.replace(/Test$/, ''), () => {
before(test.setUpClass.bind(test))
after(test.tearDownClass.bind(test))
beforeEach(test.setUp.bind(test))
afterEach(test.tearDown.bind(test))
for (let fname of Object.keys(tests)) {
it(fname, tests[fname].bind(test))
}
})
}