Skip to content

Commit

Permalink
Renamed spec file and removed testOptions2.
Browse files Browse the repository at this point in the history
  • Loading branch information
sainthkh committed Dec 4, 2019
1 parent 7292ec8 commit cea4fe8
Showing 1 changed file with 57 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,25 +298,6 @@ describe('issue #678', () => {

describe('All commands preserve options properly', () => {
const testOptions = (commandName, options, order, f) => {
const originalOptions = Object.assign({}, options)

it(commandName, () => {
let count = 0

cy.on('log:added', (attrs, log) => {
if (count === order) {
cy.removeAllListeners('log:added')
expect(log.get('options')).to.deep.eq(originalOptions)
}

count++
})

f(options)
})
}

const testOptions2 = (commandName, options, order, f) => {
it(commandName, () => {
let count = 0

Expand All @@ -334,269 +315,269 @@ describe('issue #678', () => {
}

describe('A-E', () => {
testOptions2('blur', { force: false }, 2, (options) => {
testOptions('blur', { force: false }, 2, (options) => {
cy.get('#a').focus().blur(options)
})

testOptions2('check', { force: false }, 1, (options) => {
testOptions('check', { force: false }, 1, (options) => {
cy.get('#checkbox').check(options)
})

testOptions2('children', { timeout: 2000 }, 1, (options) => {
testOptions('children', { timeout: 2000 }, 1, (options) => {
cy.get('form').children('#a', options)
})

testOptions2('clear', { force: false }, 1, (options) => {
testOptions('clear', { force: false }, 1, (options) => {
cy.get('#a').clear(options)
})

testOptions2('clearCookie', { timeout: 4000 }, 0, (options) => {
testOptions('clearCookie', { timeout: 4000 }, 0, (options) => {
cy.clearCookie('authId', options)
})

testOptions2('clearCookies', { timeout: 4000 }, 0, (options) => {
testOptions('clearCookies', { timeout: 4000 }, 0, (options) => {
cy.clearCookies(options)
})

// Ignore cy.clearLocalStorage() because it only has an option, log.

testOptions2('click', { force: false }, 1, (options) => {
testOptions('click', { force: false }, 1, (options) => {
cy.contains('button').click(options)
})

// Ignore cy.clock() because it only has an option, log.

testOptions2('closest', { timeout: 3000 }, 1, (options) => {
testOptions('closest', { timeout: 3000 }, 1, (options) => {
cy.get('#a').closest('form', options)
})

testOptions2('contains', { timeout: 1131 }, 0, (options) => {
testOptions('contains', { timeout: 1131 }, 0, (options) => {
cy.contains('.test', 'Hello', options)
})

testOptions2('dblclick', { force: false }, 1, (options) => {
testOptions('dblclick', { force: false }, 1, (options) => {
cy.get('button').dblclick(options)
})

// Ignore cy.debug() because it only has an option, log.

testOptions2('document', { timeout: 3000 }, 0, (options) => {
testOptions('document', { timeout: 3000 }, 0, (options) => {
cy.document(options)
})

// Ignore cy.each(), cy.end() because they don't have options.

testOptions2('eq', { timeout: 1111 }, 1, (options) => {
testOptions('eq', { timeout: 1111 }, 1, (options) => {
cy.get('input').eq(0, options)
})

testOptions2('exec', { env: { 'a': true } }, 0, (options) => {
testOptions('exec', { env: { 'a': true } }, 0, (options) => {
cy.exec('ls', options)
})
})

describe('F-P', () => {
testOptions2('filter', { timeout: 2222 }, 1, (options) => {
testOptions('filter', { timeout: 2222 }, 1, (options) => {
cy.get('input').filter('#a', options)
})

testOptions2('find', { timeout: 2345 }, 1, (options) => {
testOptions('find', { timeout: 2345 }, 1, (options) => {
cy.get('form').find('#a', options)
})

testOptions2('first', { timeout: 2000 }, 1, (options) => {
testOptions('first', { timeout: 2000 }, 1, (options) => {
cy.get('input').first(options)
})

// Ignore cy.fixture() because it doesn't log to reporter.

testOptions2('focus', { timeout: 2500 }, 1, (options) => {
testOptions('focus', { timeout: 2500 }, 1, (options) => {
cy.get('#a').focus(options)
})

testOptions2('focused', { timeout: 2500 }, 2, (options) => {
testOptions('focused', { timeout: 2500 }, 2, (options) => {
cy.get('#a').focus().focused(options)
})

testOptions2('get', { withinSubject: document.forms[0] }, 0, (options) => {
testOptions('get', { withinSubject: document.forms[0] }, 0, (options) => {
cy.get('#a', options)
})

testOptions2('getCookie', { timeout: 1800 }, 0, (options) => {
testOptions('getCookie', { timeout: 1800 }, 0, (options) => {
cy.getCookie('auth_key', options)
})

testOptions2('getCookies', { timeout: 1888 }, 0, (options) => {
testOptions('getCookies', { timeout: 1888 }, 0, (options) => {
cy.getCookies(options)
})

testOptions2('go', { timeout: 4000 }, 0, (options) => {
testOptions('go', { timeout: 4000 }, 0, (options) => {
cy.go('forward', options)
})

testOptions2('hash', { timeout: 1100 }, 0, (options) => {
testOptions('hash', { timeout: 1100 }, 0, (options) => {
cy.hash(options)
})

// Ignore invoke(), its() because they don't have options.

testOptions2('last', { timeout: 3000 }, 1, (options) => {
testOptions('last', { timeout: 3000 }, 1, (options) => {
cy.get('input').last(options)
})

testOptions2('location', { timeout: 2000 }, 0, (options) => {
testOptions('location', { timeout: 2000 }, 0, (options) => {
cy.location('port', options)
})

// Ignore log() because it doesn't have options.

testOptions2('next', { timeout: 2300 }, 1, (options) => {
testOptions('next', { timeout: 2300 }, 1, (options) => {
cy.get('#a').next('input', options)
})

testOptions2('nextAll', { timeout: 1211 }, 1, (options) => {
testOptions('nextAll', { timeout: 1211 }, 1, (options) => {
cy.get('#a').nextAll('input', options)
})

testOptions2('nextUntil', { timeout: 1111 }, 1, (options) => {
testOptions('nextUntil', { timeout: 1111 }, 1, (options) => {
cy.get('#a').nextUntil('#b', options)
})

testOptions2('not', { timeout: 3333 }, 1, (options) => {
testOptions('not', { timeout: 3333 }, 1, (options) => {
cy.get('input').not('#a', options)
})

testOptions2('parent', { timeout: 2345 }, 1, (options) => {
testOptions('parent', { timeout: 2345 }, 1, (options) => {
cy.get('#a').parent('form', options)
})

testOptions2('parents', { timeout: 3333 }, 1, (options) => {
testOptions('parents', { timeout: 3333 }, 1, (options) => {
cy.get('#a').parents('form', options)
})

testOptions2('parentsUntil', { timeout: 1112 }, 1, (options) => {
testOptions('parentsUntil', { timeout: 1112 }, 1, (options) => {
cy.get('#a').parentsUntil('body', options)
})

// Ignore pause() because it only has an option, log.

testOptions2('prev', { timeout: 1236 }, 1, (options) => {
testOptions('prev', { timeout: 1236 }, 1, (options) => {
cy.get('#b').prev('input', options)
})

testOptions2('prevAll', { timeout: 2111 }, 1, (options) => {
testOptions('prevAll', { timeout: 2111 }, 1, (options) => {
cy.get('#b').prevAll('input', options)
})

testOptions2('prevUntil', { timeout: 3111 }, 1, (options) => {
testOptions('prevUntil', { timeout: 3111 }, 1, (options) => {
cy.get('#b').prevUntil('#a', options)
})
})

describe('Q-Z', () => {
testOptions2('readFile', { timeout: 3000 }, 0, (options) => {
testOptions('readFile', { timeout: 3000 }, 0, (options) => {
cy.readFile('./cypress/fixtures/issue-678.html', options)
})

testOptions2('reload', { timeout: 2000 }, 0, (options) => {
testOptions('reload', { timeout: 2000 }, 0, (options) => {
cy.reload(true, options)
})

testOptions2('request', { url: '/fixtures/issue-678.html' }, 0, (options) => {
testOptions('request', { url: '/fixtures/issue-678.html' }, 0, (options) => {
cy.request(options)
})

testOptions2('rightclick', { timeout: 1144 }, 1, (options) => {
testOptions('rightclick', { timeout: 1144 }, 1, (options) => {
cy.get('button').rightclick(options)
})

testOptions2('root', { timeout: 2000 }, 0, (options) => {
testOptions('root', { timeout: 2000 }, 0, (options) => {
cy.root(options)
})

// Ignore cy.route() because it doesn't log to reporter.

testOptions2('screenshot', { capture: 'viewport' }, 0, (options) => {
testOptions('screenshot', { capture: 'viewport' }, 0, (options) => {
cy.screenshot(options)
})

testOptions2('scrollIntoView', { offset: { top: 20 } }, 1, (options) => {
testOptions('scrollIntoView', { offset: { top: 20 } }, 1, (options) => {
cy.get('form').scrollIntoView(options)
})

testOptions2('scrollTo', { duration: 100 }, 0, (options) => {
testOptions('scrollTo', { duration: 100 }, 0, (options) => {
cy.scrollTo(0, 500, options)
})

testOptions2('select', { force: false }, 1, (options) => {
testOptions('select', { force: false }, 1, (options) => {
cy.get('select').select('apples', options)
})

// Ignore cy.server() because it doesn't log to reporter.

testOptions2('setCookie', { httpOnly: true }, 0, (options) => {
testOptions('setCookie', { httpOnly: true }, 0, (options) => {
cy.setCookie('auth_key', '123key', options)
})

// Ignore cy.should() because it doesn't have options.

testOptions2('siblings', { timeout: 2223 }, 1, (options) => {
testOptions('siblings', { timeout: 2223 }, 1, (options) => {
cy.get('#a').siblings('input', options)
})

// Ignore cy.spread(), cy.spy(), cy.stub() because they don't log to reporter.

testOptions2('submit', { timeout: 2000 }, 1, (options) => {
testOptions('submit', { timeout: 2000 }, 1, (options) => {
cy.get('form').submit(options)
})

testOptions2('task', { timeout: 2000 }, 0, (options) => {
testOptions('task', { timeout: 2000 }, 0, (options) => {
cy.task('return:arg', 'hello world', options)
})

// Ignore cy.then() because it doesn't log to reporter.

// Ignore cy.tick() because it doesn't have any options.

testOptions2('title', { timeout: 2000 }, 0, (options) => {
testOptions('title', { timeout: 2000 }, 0, (options) => {
cy.title(options)
})

testOptions2('trigger', { cancelable: true }, 1, (options) => {
testOptions('trigger', { cancelable: true }, 1, (options) => {
cy.get('#a').trigger('mouseenter', 'top', options)
})

testOptions2('type', { delay: 10 }, 1, (options) => {
testOptions('type', { delay: 10 }, 1, (options) => {
cy.get('#a').type('hi?', options)
})

testOptions2('uncheck', { force: false }, 1, (options) => {
testOptions('uncheck', { force: false }, 1, (options) => {
cy.get('#checkbox').uncheck('good', options)
})

testOptions2('url', { timeout: 2000 }, 0, (options) => {
testOptions('url', { timeout: 2000 }, 0, (options) => {
cy.url(options)
})

// Ignore cy.viewport() because it only has an option, log.

// Ignore cy.visit() because it is tested in beforeEach().

testOptions2('wait', { requestTimeout: 2000 }, 0, (options) => {
testOptions('wait', { requestTimeout: 2000 }, 0, (options) => {
cy.wait(100, options)
})

testOptions2('window', { timeout: 1500 }, 0, (options) => {
testOptions('window', { timeout: 1500 }, 0, (options) => {
cy.window(options)
})

// Ignore cy.within() because it only has an option, log.

testOptions2('wrap', { timeout: 1000 }, 0, (options) => {
testOptions('wrap', { timeout: 1000 }, 0, (options) => {
cy.wrap({ name: 'John Doe' }, options)
})

testOptions2('writeFile', { timeout: 3000 }, 0, (options) => {
testOptions('writeFile', { timeout: 3000 }, 0, (options) => {
cy.writeFile('./cypress/fixtures/test.txt', 'test', options)
.exec('rm ./cypress/fixtures/test.txt')
})
Expand Down

0 comments on commit cea4fe8

Please sign in to comment.