Best JavaScript code snippet using wpt
test_contenttype.py
Source:test_contenttype.py
...39 self._dummy.initializeArchetype()40 def test_textfieldwithmime(self):41 obj = self._dummy42 field = obj.getField('atextfield')43 self.assertEqual(field.getContentType(obj), 'text/x-rst')44 self.assertEqual(field.getRaw(obj), default_text)45 obj.setAtextfield('Bla', mimetype='text/x-rst')46 self.assertEqual(field.getContentType(obj), 'text/x-rst')47 self.assertEqual(field.getRaw(obj), 'Bla')48 def test_textfieldwithmime2(self):49 obj = self._dummy50 field = obj.getField('atextfield')51 obj.setAtextfield('Bla', mimetype='text/structured')52 self.assertEqual(field.getRaw(obj), 'Bla')53 self.assertEqual(field.getContentType(obj), 'text/structured')54 def test_textfieldwithoutmime(self):55 obj = self._dummy56 field = obj.getField('atextfield')57 obj.setAtextfield('Bla')58 self.assertEqual(str(field.getRaw(obj)), 'Bla')59 self.assertEqual(field.getContentType(obj), 'text/plain')60 def test_textfielduploadwithoutmime(self):61 obj = self._dummy62 file = open(os.path.join(PACKAGE_HOME, 'input', 'rest1.tgz'), 'r')63 field = obj.getField('atextfield')64 obj.setAtextfield(file)65 file.close()66 self.assertEqual(field.getContentType(obj), 'application/x-tar')67 def test_filefieldwithmime(self):68 obj = self._dummy69 field = obj.getField('afilefield')70 obj.setAfilefield('Bla', mimetype='text/x-rst')71 self.assertEqual(str(obj.getAfilefield()), 'Bla')72 self.assertEqual(field.getContentType(obj), 'text/x-rst')73 def test_filefieldwithmime2(self):74 obj = self._dummy75 field = obj.getField('afilefield')76 obj.setAfilefield('Bla', mimetype='text/structured')77 self.assertEqual(str(obj.getAfilefield()), 'Bla')78 self.assertEqual(field.getContentType(obj), 'text/structured')79 def test_filefieldwithoutmime(self):80 obj = self._dummy81 field = obj.getField('afilefield')82 obj.setAfilefield('Bla')83 self.assertEqual(str(obj.getAfilefield()), 'Bla')84 self.assertEqual(field.getContentType(obj), 'text/plain')85 def test_filefielduploadwithoutmime(self):86 obj = self._dummy87 file = open(os.path.join(PACKAGE_HOME, 'input', 'rest1.tgz'), 'r')88 field = obj.getField('afilefield')89 obj.setAfilefield(file)90 file.close()91 self.assertEqual(field.getContentType(obj), 'application/x-tar')92class SetContentTypeTest(ATTestCase):93 def afterSetUp(self):94 gen_dummy()95 self._dummy = dummy = Dummy(oid='dummy')96 self._dummy.initializeArchetype()97 file1 = open(os.path.join(PACKAGE_HOME, 'input', 'rest1.tgz'), 'r')98 file2 = open(os.path.join(PACKAGE_HOME, 'input', 'word.doc'), 'r')99 # afilefield is the primary field100 dummy.setAfilefield(file1)101 dummy.setAnotherfilefield(file2)102 file1.close()103 file2.close()104 def testMutatorSetContentType(self):105 obj = self._dummy106 field1 = obj.getField('afilefield')107 field2 = obj.getField('anotherfilefield')108 mimetype1 = 'application/x-tar'109 mimetype2 = 'application/msword'110 self.assertEqual(field1.getContentType(obj), mimetype1)111 self.assertEqual(field2.getContentType(obj), mimetype2)112 def testBaseObjectPrimaryFieldSetContentType(self):113 obj = self._dummy114 mimetype1 = 'application/x-gzip'115 mimetype2 = 'application/pdf'116 obj.setContentType(mimetype1)117 obj.setContentType(mimetype2, 'anotherfilefield')118 self.assertEqual(obj.getContentType(), mimetype1)119 self.assertEqual(obj.getContentType('afilefield'), mimetype1)120 self.assertEqual(obj.getContentType('anotherfilefield'), mimetype2)121 def testBaseObjectSetContentType(self):122 obj = self._dummy123 mimetype1 = 'application/x-deb'124 mimetype2 = 'application/x-compressed-tar'125 obj.setContentType(mimetype1, 'afilefield')126 obj.setContentType(mimetype2, 'anotherfilefield')127 self.assertEqual(obj.getContentType(), mimetype1)128 self.assertEqual(obj.getContentType('afilefield'), mimetype1)129 self.assertEqual(obj.getContentType('anotherfilefield'), mimetype2)130 def testFieldSetContentType(self):131 obj = self._dummy132 field1 = obj.getField('afilefield')133 field2 = obj.getField('anotherfilefield')134 mimetype1 = 'image/jpeg'135 mimetype2 = 'audio/mpeg'136 field1.setContentType(obj, mimetype1)137 field2.setContentType(obj, mimetype2)138 self.assertEqual(field1.getContentType(obj), mimetype1)...
getContentType-test.js
Source:getContentType-test.js
1import getContentType from '../getContentType.js';2describe('getContentType', () => {3 it('returns text/plain for LICENSE|README|CHANGES|AUTHORS|Makefile', () => {4 expect(getContentType('AUTHORS')).toBe('text/plain');5 expect(getContentType('CHANGES')).toBe('text/plain');6 expect(getContentType('LICENSE')).toBe('text/plain');7 expect(getContentType('Makefile')).toBe('text/plain');8 expect(getContentType('PATENTS')).toBe('text/plain');9 expect(getContentType('README')).toBe('text/plain');10 });11 it('returns text/plain for .*rc files', () => {12 expect(getContentType('.eslintrc')).toBe('text/plain');13 expect(getContentType('.babelrc')).toBe('text/plain');14 expect(getContentType('.anythingrc')).toBe('text/plain');15 });16 it('returns text/plain for .git* files', () => {17 expect(getContentType('.gitignore')).toBe('text/plain');18 expect(getContentType('.gitanything')).toBe('text/plain');19 });20 it('returns text/plain for .*ignore files', () => {21 expect(getContentType('.eslintignore')).toBe('text/plain');22 expect(getContentType('.anythingignore')).toBe('text/plain');23 });24 it('returns text/plain for .ts(x) files', () => {25 expect(getContentType('app.ts')).toBe('text/plain');26 expect(getContentType('app.d.ts')).toBe('text/plain');27 expect(getContentType('app.tsx')).toBe('text/plain');28 });29 it('returns text/plain for .flow files', () => {30 expect(getContentType('app.js.flow')).toBe('text/plain');31 });32 it('returns text/plain for .lock files', () => {33 expect(getContentType('yarn.lock')).toBe('text/plain');34 });35 it('returns application/json for .map files', () => {36 expect(getContentType('react.js.map')).toBe('application/json');37 expect(getContentType('react.json.map')).toBe('application/json');38 });...
Using AI Code Generation
1var wpt = require('webpagetest');2var test = wpt('API_KEY');3test.getContentType(url, function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var wpt = require('webpagetest');11var test = wpt('API_KEY');12test.getLocations(function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var wpt = require('webpagetest');20var test = wpt('API_KEY');21test.getTesters(function(err, data) {22 if (err) {23 console.log(err);24 } else {25 console.log(data);26 }27});28var wpt = require('webpagetest');29var test = wpt('API_KEY');30var testId = '150827_7K_1c4';31test.getTestStatus(testId, function(err, data) {32 if (err) {33 console.log(err);34 } else {35 console.log(data);36 }37});38var wpt = require('webpagetest');39var test = wpt('API_KEY');40var testId = '150827_7K_1c4';41test.getTestResults(testId, function(err, data) {42 if (err) {43 console.log(err);44 } else {45 console.log(data);46 }47});48var wpt = require('webpag
Using AI Code Generation
1var wptools = require('wptools');2var wp = wptools.page('Barack Obama');3wp.getContentType(function(err, contentType) {4 if (err) {5 console.log(err);6 } else {7 console.log(contentType);8 }9});10var wptools = require('wptools');11var wp = wptools.page('Barack Obama');12wp.getCoordinates(function(err, coordinates) {13 if (err) {14 console.log(err);15 } else {16 console.log(coordinates);17 }18});19var wptools = require('wptools');20var wp = wptools.page('Barack Obama');21wp.getCoordinatesAndInfo(function(err, coordinatesAndInfo) {22 if (err) {23 console.log(err);24 } else {25 console.log(coordinatesAndInfo);26 }27});28var wptools = require('wptools');29var wp = wptools.page('Barack Obama');30wp.getCoordinatesAndDescription(function(err, coordinatesAndDescription) {31 if (err) {32 console.log(err);33 } else {34 console.log(coordinatesAndDescription);35 }36});37var wptools = require('wptools');38var wp = wptools.page('Barack Obama');39wp.getCoordinatesAndExtract(function(err, coordinatesAndExtract) {40 if (err) {41 console.log(err);42 } else {43 console.log(coordinatesAndExtract);44 }45});46var wptools = require('wptools');
Using AI Code Generation
1var wptools = require('wptools');2var wiki = wptools.page('San Francisco');3wiki.getContentType(function(err, contentType) {4 if (err) {5 console.log(err);6 } else {7 console.log(contentType);8 }9});10#### getCoordinates(callback)11var wptools = require('wptools');12var wiki = wptools.page('San Francisco');13wiki.getCoordinates(function(err, coordinates) {14 if (err) {15 console.log(err);16 } else {17 console.log(coordinates);18 }19});20#### getDisambiguation(callback)21var wptools = require('wptools');22var wiki = wptools.page('San Francisco');23wiki.getDisambiguation(function(err, disambiguation) {24 if (err) {25 console.log(err);26 } else {27 console.log(disambiguation);28 }29});30#### getExtract(callback)31var wptools = require('wptools');32var wiki = wptools.page('San Francisco');33wiki.getExtract(function(err, extract) {34 if (err) {35 console.log(err);36 } else {37 console.log(extract);38 }39});40#### getGeography(callback)41var wptools = require('wptools');
Using AI Code Generation
1var wptools = require('wptools');2var fs = require('fs');3var request = require('request');4var async = require('async');5var _ = require('underscore');6var path = require('path');7var util = require('util');8var csv = require('csv');9var csvWriter = require('csv-write-stream');10var writer = csvWriter();11var csvReader = csv();12var csvWriter = csvWriter();13var writer = csvWriter();14var input = fs.createReadStream('input.csv');15var output = fs.createWriteStream('output.csv');16var count = 0;17var results = [];18var i = 0;19var j = 0;20var k = 0;21var l = 0;22var m = 0;23var n = 0;24var o = 0;25var p = 0;26var q = 0;27var r = 0;28var s = 0;29var t = 0;30var u = 0;31var v = 0;32var w = 0;33var x = 0;34var y = 0;35var z = 0;36var aa = 0;37var ab = 0;38var ac = 0;39var ad = 0;40var ae = 0;41var af = 0;42var ag = 0;43var ah = 0;44var ai = 0;45var aj = 0;46var ak = 0;47var al = 0;48var am = 0;49var an = 0;50var ao = 0;51var ap = 0;52var aq = 0;53var ar = 0;54var as = 0;55var at = 0;56var au = 0;57var av = 0;58var aw = 0;59var ax = 0;60var ay = 0;61var az = 0;62var ba = 0;63var bb = 0;64var bc = 0;65var bd = 0;66var be = 0;67var bf = 0;68var bg = 0;69var bh = 0;70var bi = 0;71var bj = 0;72var bk = 0;73var bl = 0;74var bm = 0;75var bn = 0;76var bo = 0;77var bp = 0;78var bq = 0;
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var path = require('path');3var file = path.join(__dirname, 'test.html');4console.log(wptoolkit.getContentType(file));5var wptoolkit = require('wptoolkit');6var path = require('path');7var file = path.join(__dirname, 'test.png');8console.log(wptoolkit.getContentType(file));9var wptoolkit = require('wptoolkit');10var path = require('path');11var file = path.join(__dirname, 'test.gif');12console.log(wptoolkit.getContentType(file));13var wptoolkit = require('wptoolkit');14var path = require('path');15var file = path.join(__dirname, 'test.jpg');16console.log(wptoolkit.getContentType(file));17var wptoolkit = require('wptoolkit');18var path = require('path');19var file = path.join(__dirname, 'test.jpeg');20console.log(wptoolkit.getContentType(file));21var wptoolkit = require('wptoolkit');22var path = require('path');23var file = path.join(__dirname, 'test.js');24console.log(wptoolkit.getContentType(file));25var wptoolkit = require('wptoolkit');26var path = require('path');27var file = path.join(__dirname, 'test.css');28console.log(wptoolkit.getContentType(file));29var wptoolkit = require('wptoolkit');30var path = require('path');31var file = path.join(__dirname, 'test.json');32console.log(wptoolkit.getContentType(file));33var wptoolkit = require('
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org', 'A.2b2f3b2a7a3d3c3f7a3a3b3c3e3f3b3a3');3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log(data);7 }8});9var wpt = require('wpt');10var wpt = new WebPageTest('www.webpagetest.org', 'A.2b2f3b2a7a3d3c3f7a3a3b3c3e3f3b3a3');11wpt.getLocations(function(err, data) {12 if (err) {13 console.log('Error: ' + err);14 } else {15 console.log(data);16 }17});18var wpt = require('wpt');19var wpt = new WebPageTest('www.webpagetest.org', 'A.2b2f3b2a7a3d3c3f7a3a3b3c3e3f3b3a3');20wpt.getTesters(function(err, data) {21 if (err) {22 console.log('Error: ' + err);23 } else {24 console.log(data);25 }26});27var wpt = require('wpt');28var wpt = new WebPageTest('www.webpagetest.org', 'A.2b2f3b2a7a3d3c3f7a3a3b3c3e3f3b3a3');29wpt.getLocations(function(err, data) {30 if (err) {31 console.log('Error: ' + err);32 } else {33 console.log(data);34 }35});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!