it('def should create definition file with inject which contains I object from helpers', (done) => { exec(`${runner} def --config ${codecept_dir}//codecept.inject.powi.json`, () => { const types = typesFrom(`${codecept_dir}/steps.d.ts`); types.should.be.valid; const definitionsFile = types.getSourceFileOrThrow(pathOfStaticDefinitions); const returned = getReturnStructure(definitionsFile.getFunctionOrThrow('inject')); returned.should.containSubset([{ properties: [{ name: 'I', type: 'CodeceptJS.I' }], }]); done(); }); });
describe('#methodsOfObject', () => { it('should get methods', () => { utils.methodsOfObject({ a: 1, hello: () => {}, world: () => {}, }).should.eql(['hello', 'world']); }); });
it('def should create definition file with inject which contains I object', (done) => { exec(`${runner} def --config ${codecept_dir}/codecept.inject.po.json`, (err, stdout, stderr) => { assert(!err); const types = typesFrom(`${codecept_dir}/steps.d.ts`); types.should.be.valid; const definitionsFile = types.getSourceFileOrThrow(pathOfStaticDefinitions); const returned = getReturnStructure(definitionsFile.getFunctionOrThrow('inject')); returned.should.containSubset([ { properties: [ { name: 'I', type: 'CodeceptJS.I' }, { name: 'MyPage', type: 'MyPage' }, ], }, ]); done(); }); });
describe('#Metrics', () => { it('should return a Metrics instance with correct default options', () => { const metrics = new Metrics(); metrics.should.be.instanceof(Metrics); metrics.should.have.property('id', 'unknown'); metrics.endpoints.should.be.instanceof(Array); metrics.endpoints.should.be.empty; metrics.data.should.be.instanceof(Object); metrics.data.should.be.empty; metrics.log.should.be.instanceof(EventEmitter); }); it('should return a Metrics instance with user options', () => { const metrics = new Metrics({id: '24601', endpoints: [1, 2], data: {prisoner: 'valjean'}}); metrics.should.be.instanceof(Metrics); metrics.should.have.property('id', '24601'); metrics.data.prisoner.should.equal('valjean'); metrics.endpoints.should.have.length(2); metrics.endpoints.should.be.not.empty; metrics.data.should.be.not.empty; metrics.log.should.be.instanceof(EventEmitter); }); });
])).then(res => { debugLog(JSON.stringify(res)); res.should.be.deepEqual(
describe('#cliPkgTask', () => { it('should return yarn --production as first command', () => { const command = util.cliPkgTask('thing'); command[0].should.equal('yarn install --production'); }); const command = util.cliPkgTask('thing'); const parts = command[1].split(' '); parts[7].should.equal('thing'); }); const command = util.cliPkgTask('thing'); const os = command[1].split(' ')[3].split('-')[1]; os.should.equal(target); }); setPlatform('darwin'); const c1 = util.cliPkgTask('thing'); c1[2].should.equal('chmod +x thing'); c1[3].should.equal('sleep 2'); resetPlatform(); setPlatform('linux'); const c2 = util.cliPkgTask('thing'); c2[2].should.equal('chmod +x thing'); c2[3].should.equal('sleep 2'); resetPlatform(); }); setPlatform('win32'); const command = util.cliPkgTask('thing');
`); return compiler.compile().then(() => { contextEvaluator.contextList.should.be.deepEqual( ['Marketing'] );
return shell.sh(['slip', 'sliding', 'away']) .then(result => { result.should.equal('EXEC: slip sliding away'); }) .then(_shell.exec.restore()) .should.be.fulfilled; }); return shell.sh(['tupelo', 'honey', 'baby'], opts) .then(result => { result.should.equal('SPAWN: tupelo honey baby'); }) .should.be.fulfilled; }); child.spawn.restore(); const shell = new Shell(); sinon.stub(child, 'spawn').callsFake(fakeSpawn); return shell.sh(['set', 'us', 'up', 'the', 'bomb'], {mode: 'attach'}).should.be.rejected .then(child.spawn.restore()); }); const shell = new Shell(); sinon.stub(child, 'spawn').callsFake(fakeSpawn); return shell.sh(['van', 'the', 'man'], {detached: true}).should.be.fulfilled .then(child.spawn.restore()); }); process.lando = 'browser';
it('should return an events instance with correct default options', () => { const events = new AsyncEvents(); events.should.be.instanceof(AsyncEvents); events.should.be.an('object').with.property('log'); events.should.have.property('_maxListeners', 64); events._listeners.should.be.an('array').and.be.empty; events.should.have.property('_eventsCount', 0); }); const log = sinon.spy(); const events = new AsyncEvents(log); events.should.have.property('log', log); }); }); .filter(event => event.priority === 5) .size(); priorityFiveEvents.should.equal(2); }); events.on('event', 6, after); events.emit('event').then(() => { before.should.be.calledBefore(middle); middle.should.be.calledBefore(after); after.should.be.calledAfter(middle); }); }); it('should return a promise', () => {
}) .catch((error) => { error.should.be.instanceof(CompileError); }); }); throw new Error(); }).catch((error) => { error.should.be.instanceof(CompileError); }); }); res.should.be.deepEqual( res.should.be.deepEqual( res.should.be.deepEqual(responses[index]); })); }); }); console.log(query.buildSqlAndParams()); query.buildSqlAndParams()[0].should.match(/bar/); }); }); `); return compiler.compile().then(() => { contextEvaluator.contextList.should.be.deepEqual(
it('def should create definition file with inject which contains support objects', (done) => { exec(`${runner} def --config ${codecept_dir}/codecept.inject.po.json`, () => { const types = typesFrom(`${codecept_dir}/steps.d.ts`); types.should.be.valid; const definitionsFile = types.getSourceFileOrThrow(pathOfStaticDefinitions); const returned = getReturnStructure(definitionsFile.getFunctionOrThrow('inject')); returned.should.containSubset([{ properties: [ { name: 'SecondPage', type: 'SecondPage' }, { name: 'MyPage', type: 'MyPage' }, ], }]); done(); }); });
])).then(res => { debugLog(JSON.stringify(res)); res.should.be.deepEqual(