/**
* The test item
*/
/*
class TestItem {
constructor(name, isSuccess) {
this.isSuccess = isSuccess
this.name= name
}
async runTest() {
console.log('~>Test running')
return await new Promise((resolve, reject) => {
let wait = setTimeout(() => {
console.log('<~Test completed')
resolve('Promise resolved!');
}, 1000)
})
}
test() {
return this.runTest()
.finally(() => {
this.isSuccess()
})
}
}
*/
class TestItem {
/*
name = ''
type = null
tested = false
resultJson = null
responseStatusCode = null
isSuccess = () => {
console.log('isSuccess() not implemented')
return this.responseStatusCode === 200
}
runTest = () => { return null }
*/
/**
* @summary Creates a test item.
* @param {*} name The name of the test.
* @param {*} type The type of the test.
* @param {*} isSuccess The function that tells whenter the test passed or failed.
* @param {*} runTest The function to test.
*/
constructor(name, type, isSuccess, runTest) {
this.name = name
this.type = type
this.isSuccess = isSuccess
this.runTest = runTest
this.tested = false
this.resultJson = null
this.responseStatusCode = null
//console.log(`TestItem: `, this)
}
/**
* @summary Prepares the test prior to run.
*/
prepareBeforeRunning() {
this.running = true
this.tested = false
this.success = null
this.error = null
}
/**
* @summary Runs the test with parameters from this.props
* @returns The runTest promise
*/
test( /*updateTestItem*/ ) {
// Prepare the test by reseting runtime information (and render display)
console.log(`~~⇝ Test ${this.name} running`)
this.prepareBeforeRunning()
//updateTestItem(this.id, this)
// Run the test…
return this.runTest()
.then(json => {
// The test has already been tested (ran).
this.tested = true
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.