Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(mv3): merge mv3 tests into mv2 test files #1247

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"test:e2e": "mocha --timeout 300000 \"test/e2e/**/*.test.js\"",
"test:functional": "c8 mocha --timeout 5000 --file \"test/setup/mocha-setup.js\" \"test/functional/**/*.test.js\" \"test/functional/**/*.test.ts\"",
"lint": "run-s lint:*",
"test:functional_MV3": "cross-env TEST_MV3=true c8 mocha --timeout 5000 --file \"test/setup/mocha-setup.js\" \"test/functional/**/*.test.mv3.js\"",
"test:functional_MV3": "cross-env TEST_MV3=true c8 mocha --timeout 5000 --file \"test/setup/mocha-setup.js\" \"test/functional/**/*.test.js\" \"test/functional/**/*.test.ts\"",
"lint:standard": "ts-standard -v \"*.js\" \"add-on/src/**/*.js\" \"add-on/src/**/*.ts\" \"test/**/*.js\" \"scripts/**/*.js\"",
"lint:web-ext": "shx cat add-on/manifest.common.json add-on/manifest.chromium.json add-on/manifest.firefox-beta.json | json --deep-merge > add-on/manifest.json && web-ext lint --firefox-preview",
"fix:lint": "run-s fix:lint:*",
Expand Down
20 changes: 1 addition & 19 deletions test/functional/lib/ipfs-companion.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { describe, it, before, after } from 'mocha'
import { expect } from 'chai'
import { after, before, describe, it } from 'mocha'
import browser from 'sinon-chrome'
import AbortController from 'abort-controller'
import { URL } from 'url'
import { optionDefaults } from '../../../add-on/src/lib/options.js'

Expand All @@ -10,17 +9,6 @@ import { optionDefaults } from '../../../add-on/src/lib/options.js'
const init = async () => (await import('../../../add-on/src/lib/ipfs-companion.js')).default()

describe('lib/ipfs-companion.js', function () {
before(function () {
browser.runtime.id = 'testid'
global.browser = browser
global.AbortController = AbortController
global.chrome = browser
global.navigator = {
clipboard: {
writeText: () => {}
}
}
})
describe('init', function () {
before(function () {
global.localStorage = global.localStorage || {}
Expand All @@ -47,12 +35,6 @@ describe('lib/ipfs-companion.js', function () {
})

describe.skip('onStorageChange()', function () {
before(function () {
global.window = {}
global.browser = browser
global.URL = URL
})

it('should update ipfs API instance on IPFS API URL change', async function () {
browser.storage.local.get.resolves(optionDefaults)
browser.storage.local.set.resolves()
Expand Down
24 changes: 1 addition & 23 deletions test/functional/lib/ipfs-import.test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
'use strict'
import { describe, it, before, after } from 'mocha'
import { expect } from 'chai'
import { useFakeTimers } from 'sinon'
import browser from 'sinon-chrome'
import { describe, it } from 'mocha'
import { formatImportDirectory } from '../../../add-on/src/lib/ipfs-import.js'

describe('ipfs-import.js', function () {
before(function () {
browser.runtime.id = 'testid'
global.document = {}
global.browser = browser
// ipfs-import depends on webextension/polyfill which can't be imported
// in a non-browser environment unless global.browser is stubbed

// need to force Date to return a particular date
global.clock = useFakeTimers({
now: new Date(2017, 10, 5, 12, 1, 1)
})
})

describe('formatImportDirectory', function () {
it('should change nothing if path is properly formatted and date wildcards are not provided', function () {
const path = '/ipfs-companion-imports/my-directory/'
Expand Down Expand Up @@ -54,11 +39,4 @@ describe('ipfs-import.js', function () {
//
// describe('importFiles', function () {
// })

after(function () {
global.browser.flush()
global.clock.restore()
delete global.document
delete global.browser
})
})
15 changes: 9 additions & 6 deletions test/functional/lib/ipfs-request-dnslink.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict'
import { describe, it, before, beforeEach, after } from 'mocha'
import sinon from 'sinon'
import { expect } from 'chai'
import { URL } from 'url'
import { after, before, beforeEach, describe, it } from 'mocha'
import sinon from 'sinon'
import browser from 'sinon-chrome'
import { initState } from '../../../add-on/src/lib/state.js'
import createRuntimeChecks from '../../../add-on/src/lib/runtime-checks.js'
import { createRequestModifier } from '../../../add-on/src/lib/ipfs-request.js'
import createDnslinkResolver from '../../../add-on/src/lib/dnslink.js'
import { createIpfsPathValidator } from '../../../add-on/src/lib/ipfs-path.js'
import { createRequestModifier } from '../../../add-on/src/lib/ipfs-request.js'
import { optionDefaults } from '../../../add-on/src/lib/options.js'
import createRuntimeChecks from '../../../add-on/src/lib/runtime-checks.js'
import { initState } from '../../../add-on/src/lib/state.js'
import isMv3TestingEnabled from '../../helpers/is-mv3-testing-enabled.js'

const url2request = (string) => {
return { url: string, type: 'main_frame' }
Expand All @@ -23,6 +23,9 @@ describe('modifyRequest processing of DNSLinks', function () {
let state, dnslinkResolver, ipfsPathValidator, modifyRequest, runtime

before(function () {
if (isMv3TestingEnabled) {
return this.skip()
}
global.URL = URL
global.browser = browser
browser.runtime.id = 'testid'
Expand Down
12 changes: 6 additions & 6 deletions test/functional/lib/ipfs-request-gateway-recover.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict'
import { describe, it, before, beforeEach, after, afterEach } from 'mocha'
import sinon from 'sinon'
import { assert } from 'chai'
import { URL } from 'url'
import { after, afterEach, before, beforeEach, describe, it } from 'mocha'
import sinon from 'sinon'
import browser from 'sinon-chrome'
import { initState } from '../../../add-on/src/lib/state.js'
import createRuntimeChecks from '../../../add-on/src/lib/runtime-checks.js'
import { createRequestModifier } from '../../../add-on/src/lib/ipfs-request.js'
import { URL } from 'url'
import createDnslinkResolver from '../../../add-on/src/lib/dnslink.js'
import { createIpfsPathValidator } from '../../../add-on/src/lib/ipfs-path.js'
import { createRequestModifier } from '../../../add-on/src/lib/ipfs-request.js'
import { optionDefaults } from '../../../add-on/src/lib/options.js'
import createRuntimeChecks from '../../../add-on/src/lib/runtime-checks.js'
import { initState } from '../../../add-on/src/lib/state.js'

browser.runtime.id = 'testid'

Expand Down
Loading