Skip to content

Commit

Permalink
[js] replacing asserts equal with strictEqual and deepEqual with deep…
Browse files Browse the repository at this point in the history
…StrictEqual
  • Loading branch information
harsha509 committed Mar 23, 2021
1 parent a08fa1e commit 43ab383
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 272 deletions.
27 changes: 13 additions & 14 deletions javascript/node/selenium-webdriver/test/chrome/devtools_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const fileServer = require('../../lib/test/fileserver')
const io = require('../../io')
const test = require('../../lib/test')
const until = require('../../lib/until')
const Server = require('../../lib/test/httpserver').Server

test.suite(
function (env) {
Expand All @@ -43,31 +42,31 @@ test.suite(

it('can send commands to devtools', async function () {
await driver.get(test.Pages.ajaxyPage)
assert.equal(await driver.getCurrentUrl(), test.Pages.ajaxyPage)
assert.strictEqual(await driver.getCurrentUrl(), test.Pages.ajaxyPage)

await driver.sendDevToolsCommand('Page.navigate', {
url: test.Pages.echoPage,
})
assert.equal(await driver.getCurrentUrl(), test.Pages.echoPage)
assert.strictEqual(await driver.getCurrentUrl(), test.Pages.echoPage)
})

it('can send commands to devtools and get return', async function () {
await driver.get(test.Pages.ajaxyPage)
assert.equal(await driver.getCurrentUrl(), test.Pages.ajaxyPage)
assert.strictEqual(await driver.getCurrentUrl(), test.Pages.ajaxyPage)

await driver.get(test.Pages.echoPage)
assert.equal(await driver.getCurrentUrl(), test.Pages.echoPage)
assert.strictEqual(await driver.getCurrentUrl(), test.Pages.echoPage)

let history = await driver.sendAndGetDevToolsCommand(
'Page.getNavigationHistory'
)
assert(history)
assert(history.currentIndex >= 2)
assert.equal(
assert.strictEqual(
history.entries[history.currentIndex].url,
test.Pages.echoPage
)
assert.equal(
assert.strictEqual(
history.entries[history.currentIndex - 1].url,
test.Pages.ajaxyPage
)
Expand Down Expand Up @@ -100,15 +99,15 @@ test.suite(
it('calls the event listener for console.log', async function () {
const cdpConnection = await driver.createCDPConnection('page')
await driver.onLogEvent(cdpConnection, function (event) {
assert.equal(event['args'][0]['value'], 'here')
assert.strictEqual(event['args'][0]['value'], 'here')
})
await driver.executeScript('console.log("here")')
})

it('calls the event listener for js exceptions', async function () {
const cdpConnection = await driver.createCDPConnection('page')
await driver.onLogException(cdpConnection, function (event) {
assert.equal(
assert.strictEqual(
event['exceptionDetails']['stackTrace']['callFrames'][0][
'functionName'
],
Expand All @@ -125,9 +124,9 @@ test.suite(
it('calls the event listener on dom mutations', async function () {
const cdpConnection = await driver.createCDPConnection('page')
await driver.logMutationEvents(cdpConnection, function (event) {
assert.equal(event['attribute_name'], 'style')
assert.equal(event['current_value'], '')
assert.equal(event['old_value'], 'display:none;')
assert.strictEqual(event['attribute_name'], 'style')
assert.strictEqual(event['current_value'], '')
assert.strictEqual(event['old_value'], 'display:none;')
})

await driver.get(fileServer.Pages.dynamicPage)
Expand Down Expand Up @@ -156,7 +155,7 @@ test.suite(
await driver.register('genie', 'bottle', pageCdpConnection)
await driver.get(fileServer.Pages.basicAuth)
let source = await driver.getPageSource()
assert.equal(source.includes('Access granted!'), true)
assert.strictEqual(source.includes('Access granted!'), true)
})
})

Expand All @@ -178,7 +177,7 @@ test.suite(
__dirname,
'../../lib/test/data/firefox/webextension.xpi'
)
assert.equal(
assert.strictEqual(
fs.readFileSync(downloadPath, 'binary'),
fs.readFileSync(goldenPath, 'binary')
)
Expand Down
18 changes: 9 additions & 9 deletions javascript/node/selenium-webdriver/test/chrome/options_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ describe('chrome.Options', function () {
describe('addArguments', function () {
it('takes var_args', function () {
let options = new chrome.Options()
assert.deepEqual(options[symbols.serialize](), {
assert.deepStrictEqual(options[symbols.serialize](), {
browserName: 'chrome',
'goog:chromeOptions': {},
})

options.addArguments('a', 'b')
assert.deepEqual(options[symbols.serialize](), {
assert.deepStrictEqual(options[symbols.serialize](), {
browserName: 'chrome',
'goog:chromeOptions': {
args: ['a', 'b'],
Expand All @@ -44,13 +44,13 @@ describe('chrome.Options', function () {

it('flattens input arrays', function () {
let options = new chrome.Options()
assert.deepEqual(options[symbols.serialize](), {
assert.deepStrictEqual(options[symbols.serialize](), {
browserName: 'chrome',
'goog:chromeOptions': {},
})

options.addArguments(['a', 'b'], 'c', [1, 2], 3)
assert.deepEqual(options[symbols.serialize](), {
assert.deepStrictEqual(options[symbols.serialize](), {
browserName: 'chrome',
'goog:chromeOptions': {
args: ['a', 'b', 'c', 1, 2, 3],
Expand All @@ -65,15 +65,15 @@ describe('chrome.Options', function () {
assert.strictEqual(options.options_.extensions, undefined)

options.addExtensions('a', 'b')
assert.deepEqual(options.options_.extensions, ['a', 'b'])
assert.deepStrictEqual(options.options_.extensions, ['a', 'b'])
})

it('flattens input arrays', function () {
let options = new chrome.Options()
assert.strictEqual(options.options_.extensions, undefined)

options.addExtensions(['a', 'b'], 'c', [1, 2], 3)
assert.deepEqual(options.options_.extensions, ['a', 'b', 'c', 1, 2, 3])
assert.deepStrictEqual(options.options_.extensions, ['a', 'b', 'c', 1, 2, 3])
})
})

Expand All @@ -84,8 +84,8 @@ describe('chrome.Options', function () {
.addExtensions(__filename)
[symbols.serialize]()

assert.equal(wire['goog:chromeOptions'].extensions.length, 1)
assert.equal(await wire['goog:chromeOptions'].extensions[0], expected)
assert.strictEqual(wire['goog:chromeOptions'].extensions.length, 1)
assert.strictEqual(await wire['goog:chromeOptions'].extensions[0], expected)
})
})
})
Expand All @@ -109,7 +109,7 @@ test.suite(
var userAgent = await driver.executeScript(
'return window.navigator.userAgent'
)
assert.equal(userAgent, 'foo;bar')
assert.strictEqual(userAgent, 'foo;bar')
})
})
},
Expand Down
12 changes: 6 additions & 6 deletions javascript/node/selenium-webdriver/test/http/http_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,21 @@ describe('HttpClient', function () {

const client = new HttpClient(server.url(), agent)
return client.send(request).then(function (response) {
assert.equal(200, response.status)
assert.strictEqual(200, response.status)

const headers = JSON.parse(response.body)
assert.equal(headers['content-length'], '0')
assert.equal(headers['connection'], 'keep-alive')
assert.equal(headers['host'], server.host())
assert.strictEqual(headers['content-length'], '0')
assert.strictEqual(headers['connection'], 'keep-alive')
assert.strictEqual(headers['host'], server.host())

const regex = /^selenium\/.* \(js (windows|mac|linux)\)$/
assert.ok(
regex.test(headers['user-agent']),
`${headers['user-agent']} does not match ${regex}`
)

assert.equal(request.headers.get('Foo'), 'Bar')
assert.equal(
assert.strictEqual(request.headers.get('Foo'), 'Bar')
assert.strictEqual(
request.headers.get('Accept'),
'application/json; charset=utf-8'
)
Expand Down
6 changes: 3 additions & 3 deletions javascript/node/selenium-webdriver/test/http/util_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('selenium-webdriver/http/util', function () {
describe('#getStatus', function () {
it('should return value field on success', function () {
return util.getStatus(baseUrl).then(function (response) {
assert.equal('abc123', response)
assert.strictEqual('abc123', response)
})
})

Expand All @@ -79,8 +79,8 @@ describe('selenium-webdriver/http/util', function () {
},
function (err) {
assert.ok(err instanceof error.WebDriverError)
assert.equal(err.code, error.WebDriverError.code)
assert.equal(err.message, value)
assert.strictEqual(err.code, error.WebDriverError.code)
assert.strictEqual(err.message, value)
}
)
})
Expand Down
8 changes: 4 additions & 4 deletions javascript/node/selenium-webdriver/test/ie/options_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test.suite(
caps = caps.map_.get(ie.VENDOR_COMMAND_PREFIX)[
ie.Key.ELEMENT_SCROLL_BEHAVIOR
]
assert.equal(caps, ie.Behavior.TOP)
assert.strictEqual(caps, ie.Behavior.TOP)
await driver.quit()
})

Expand All @@ -90,16 +90,16 @@ test.suite(
caps = caps.map_.get(ie.VENDOR_COMMAND_PREFIX)[
ie.Key.BROWSER_COMMAND_LINE_SWITCHES
]
assert.equal(caps, '-k -private')
assert.strictEqual(caps, '-k -private')
await driver.quit()
})

it('can set capability', async function () {
let caps = Capabilities.ie()
assert.ok(!caps.has('silent'))
assert.equal(undefined, caps.get('silent'))
assert.strictEqual(undefined, caps.get('silent'))
caps.set('silent', true)
assert.equal(true, caps.get('silent'))
assert.strictEqual(true, caps.get('silent'))
assert.ok(caps.has('silent'))
})
})
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/test/io/zip_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('io/zip', function () {
return z.getFile('foo')
})
.then((buffer) =>
assert.equal(buffer.toString('utf8'), 'hello, world!')
assert.strictEqual(buffer.toString('utf8'), 'hello, world!')
)
})

Expand Down
Loading

0 comments on commit 43ab383

Please sign in to comment.