MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / findEditUrl

Function findEditUrl

tests/testFileEditor.js:473–500  ·  view source on GitHub ↗
(name, selector, url, expectedEditUrl)

Source from the content-addressed store, hash-verified

471}
472
473function findEditUrl(name, selector, url, expectedEditUrl) {
474 describe(`GET to ${name}`, function() {
475 it('should load successfully', function(callback) {
476 locals.preStartTime = Date.now();
477 request(url, function (error, response, body) {
478 if (error) {
479 return callback(error);
480 }
481 locals.postStartTime = Date.now();
482 if (response.statusCode != 200) {
483 return callback(new Error('bad status: ' + response.statusCode));
484 }
485 page = body;
486 callback(null);
487 });
488 });
489 it('should parse', function() {
490 locals.$ = cheerio.load(page);
491 });
492 it(`should contain edit link at ${selector}`, function() {
493 elemList = locals.$(selector);
494 assert.lengthOf(elemList, 1);
495 });
496 it(`should match expected url in edit link`, function() {
497 assert.equal(siteUrl + elemList[0].attribs.href, expectedEditUrl);
498 });
499 });
500}
501
502function verifyEdit(expectedToFindResults, expectedToFindChoice, expectedDraftContents, expectedDiskContents) {
503 it('should have a CSRF token', function() {

Callers 1

testFileEditor.jsFile · 0.85

Calls 2

itFunction · 0.85
callbackFunction · 0.85

Tested by

no test coverage detected