it( 'should display image only when provided', () => { const wrapperNoImage = shallow( <Twitter /> ); const wrapperWithImage = shallow( <Twitter image={ IMAGE_SRC_FIXTURE } /> ); const tweetWrapperNoImage = wrapperNoImage.find( Tweet ).dive(); const tweetWrapperWithImage = wrapperWithImage.find( Tweet ).dive(); // No image expect( tweetWrapperNoImage.find( '.twitter-preview__card-image' ).exists() ).toBeFalsy(); // Has image const imageEl = tweetWrapperWithImage.find( '.twitter-preview__card-image' ); expect( imageEl.exists() ).toBeTruthy(); expect( imageEl.html() ).toContain( `src="${ IMAGE_SRC_FIXTURE }"` ); } );
/** * {{> seeElementInDOM }} */ async seeElementInDOM(locator) { const exists = (await findElements.call(this, this.context, locator)).exists; return this.t .expect(exists).ok(`No element "${locator}" found in DOM`) .catch(mapError); }
/** * {{> waitToHide }} */ async waitToHide(locator, sec) { const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout; return this.t .expect(createSelector(locator).filterHidden().with({ boundTestRun: this.t }).exists) .notOk({ timeout: waitTimeout }); }
async resolve(from: string) { const configCandidates = configLookup(this.configFile, from) const { exists, load, none } = this.io for (const candidate of configCandidates) { if (await exists(candidate)) { return load(candidate) } } return none(from) }
test('@taskr/clear: directory', co(function * (t) { t.plan(1); yield create({ * a(f) { const src = `${dir1}/foo`; yield f.$.write(src); yield f.clear(dir1); t.false(exists(src), 'directory was deleted'); } }).start('a'); }));
async classExists(name: string) { return this._client.one( 'SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = $1)', [name], (a) => a.exists ); }
describe('<HeaderModalNavContainer />', () => { it('should not crash', () => { shallow(<HeaderModalNavContainer />); }); it('should render its children', () => { const Child = () => <div>Some child</div>; const wrapper = shallow(<HeaderModalNavContainer><Child /></HeaderModalNavContainer>); expect(wrapper.find(Child).exists()).toBe(true); }); });
it( 'should display a (hard) truncated description', () => { const wrapper = shallow( <Facebook description="I know the kings of England, and I quote the fights historical, From Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical, I understand equations, both the simple and quadratical; About binomial theorem I'm teeming with a lot o' news, With many cheerful facts about the square of the hypotenuse." /> ); const descEl = wrapper.find( '.facebook-preview__description' ); expect( descEl.exists() ).toBeTruthy(); expect( descEl.text() ).toEqual( "I know the kings of England, and I quote the fights historical, From Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical, I understand equations, both …" ); const descTextNoEllipsis = descEl.text().replace( '…', '' ); expect( descTextNoEllipsis ).toHaveLength( 200 ); } );
events.on('activeValues', function() { var valuesModal = dataCenter.valuesModal; if (valuesModal.exists(dataCenter.activeValuesName)) { self.setValuesActive(dataCenter.activeValuesName, valuesModal); self.setState({}); } });
function writeMarker(filename) { if (! exists(filename)) { writeFile(filename, "") } }
describe('Spinner', () => { it('should render the spinner', () => { const spinner = shallow(<Spinner />) assert(spinner.find('div').exists()) }) })
/** * {{> waitForElement }} */ async waitForElement(locator, sec) { const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout; return this.t .expect(createSelector(locator).with({ boundTestRun: this.t }).exists) .ok({ timeout: waitTimeout }); }
/** * {{> waitForInvisible }} */ async waitForInvisible(locator, sec) { const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout; return this.t .expect(createSelector(locator).filterVisible().with({ boundTestRun: this.t }).exists) .ok({ timeout: waitTimeout }); }
describe('<HeaderModalNavContainer />', () => { it('should not crash', () => { shallow(<HeaderModalNavContainer />); }); it('should render its children', () => { const Child = () => <div>Some child</div>; const wrapper = shallow(<HeaderModalNavContainer><Child /></HeaderModalNavContainer>); expect(wrapper.find(Child).exists()).toBe(true); }); });
test('@taskr/clear: directory', co(function * (t) { t.plan(1); yield create({ * a(f) { const src = `${dir1}/foo`; yield f.$.write(src); yield f.clear(dir1); t.false(exists(src), 'directory was deleted'); } }).start('a'); }));